Moved Objects
This commit is contained in:
parent
848a2a78e3
commit
6c67e97a4b
167 changed files with 368 additions and 373 deletions
88
src/TgBotLib/Objects/BotCommandScope/BotCommandScopeChat.php
Normal file
88
src/TgBotLib/Objects/BotCommandScope/BotCommandScopeChat.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
use TgBotLib\Enums\Types\BotCommandScopeType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\BotCommandScope;
|
||||
|
||||
class BotCommandScopeChat 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public function getChatId(): int|string
|
||||
{
|
||||
return $this->chat_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'chat_id' => $this->chat_id
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return BotCommandScopeChat
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['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