Updated BotCommandScope
This commit is contained in:
parent
6c67e97a4b
commit
79278e7748
8 changed files with 66 additions and 362 deletions
|
@ -8,27 +8,12 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
class BotCommandScopeChat implements ObjectTypeInterface
|
||||
class BotCommandScopeChat extends BotCommandScope implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var int|string
|
||||
*/
|
||||
private $chat_id;
|
||||
|
||||
/**
|
||||
* Scope type, must be chat
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
private int|string $chat_id;
|
||||
|
||||
/**
|
||||
* Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
||||
|
@ -41,48 +26,25 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'type' => $this->type->value,
|
||||
'chat_id' => $this->chat_id
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return BotCommandScopeChat
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? BotCommandScopeType::CHAT;
|
||||
$object->type = BotCommandScopeType::CHAT;
|
||||
$object->chat_id = $data['chat_id'] ?? null;
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from BotCommandScope
|
||||
*
|
||||
* @param BotCommandScope $botCommandScope
|
||||
* @return static
|
||||
*/
|
||||
public static function fromBotCommandScope(BotCommandScope $botCommandScope): self
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $botCommandScope->getType();
|
||||
$object->chat_id = $botCommandScope->getChatId();
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue