2023-02-13 20:23:50 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/** @noinspection PhpMissingFieldTypeInspection */
|
|
|
|
|
2023-02-14 17:41:38 -05:00
|
|
|
namespace TgBotLib\Objects\Telegram\BotCommandScope;
|
2023-02-13 20:23:50 -05:00
|
|
|
|
2023-08-09 15:32:45 -04:00
|
|
|
use TgBotLib\Enums\BotCommandScopeType;
|
2023-02-13 20:23:50 -05:00
|
|
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
2023-02-14 17:41:38 -05:00
|
|
|
use TgBotLib\Objects\Telegram\BotCommandScope;
|
2023-02-13 20:23:50 -05:00
|
|
|
|
|
|
|
class BotCommandScopeAllGroupChats implements ObjectTypeInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scope type, must be all_group_chats
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getType(): string
|
|
|
|
{
|
|
|
|
return $this->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array representation of the object
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'type' => $this->type
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs object from an array representation
|
|
|
|
*
|
|
|
|
* @param array $data
|
2023-02-16 15:27:57 -05:00
|
|
|
* @return BotCommandScopeAllGroupChats
|
2023-02-13 20:23:50 -05:00
|
|
|
*/
|
2023-02-16 15:27:57 -05:00
|
|
|
public static function fromArray(array $data): self
|
2023-02-13 20:23:50 -05:00
|
|
|
{
|
|
|
|
$object = new self();
|
|
|
|
|
2023-08-09 15:32:45 -04:00
|
|
|
$object->type = $data['type'] ?? BotCommandScopeType::ALL_CHAT_GROUPS;
|
2023-02-13 20:23:50 -05:00
|
|
|
|
|
|
|
return $object;
|
|
|
|
}
|
2023-02-13 20:33:55 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs object from BotCommandScope
|
|
|
|
*
|
|
|
|
* @param BotCommandScope $botCommandScope
|
|
|
|
* @return BotCommandScopeAllGroupChats
|
|
|
|
*/
|
|
|
|
public static function fromBotCommandScope(BotCommandScope $botCommandScope): BotCommandScopeAllGroupChats
|
|
|
|
{
|
|
|
|
$object = new self();
|
|
|
|
|
|
|
|
$object->type = $botCommandScope->getType();
|
|
|
|
|
|
|
|
return $object;
|
|
|
|
}
|
2023-02-13 20:23:50 -05:00
|
|
|
}
|