2023-02-13 20:27:09 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/** @noinspection PhpMissingFieldTypeInspection */
|
|
|
|
|
2024-10-02 00:18:12 -04:00
|
|
|
namespace TgBotLib\Objects\BotCommandScope;
|
2023-02-13 20:27:09 -05:00
|
|
|
|
2024-09-29 21:49:10 -04:00
|
|
|
use TgBotLib\Enums\Types\BotCommandScopeType;
|
2023-02-13 20:27:09 -05:00
|
|
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
2024-10-02 00:18:12 -04:00
|
|
|
use TgBotLib\Objects\BotCommandScope;
|
2023-02-13 20:27:09 -05:00
|
|
|
|
2024-10-02 00:32:13 -04:00
|
|
|
class BotCommandScopeChat extends BotCommandScope implements ObjectTypeInterface
|
2023-02-13 20:27:09 -05:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var int|string
|
|
|
|
*/
|
2024-10-02 00:32:13 -04:00
|
|
|
private int|string $chat_id;
|
2023-02-13 20:27:09 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-10-02 00:32:13 -04:00
|
|
|
* @inheritDoc
|
2023-02-13 20:27:09 -05:00
|
|
|
*/
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return [
|
2024-10-02 00:32:13 -04:00
|
|
|
'type' => $this->type->value,
|
2023-02-13 20:27:09 -05:00
|
|
|
'chat_id' => $this->chat_id
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-10-02 00:32:13 -04:00
|
|
|
* @inheritDoc
|
2023-02-13 20:27:09 -05:00
|
|
|
*/
|
2023-02-16 15:27:57 -05:00
|
|
|
public static function fromArray(array $data): self
|
2023-02-13 20:27:09 -05:00
|
|
|
{
|
|
|
|
$object = new self();
|
2024-10-02 00:32:13 -04:00
|
|
|
$object->type = BotCommandScopeType::CHAT;
|
2023-02-14 17:35:16 -05:00
|
|
|
$object->chat_id = $data['chat_id'] ?? null;
|
2023-02-13 20:27:09 -05:00
|
|
|
|
|
|
|
return $object;
|
|
|
|
}
|
|
|
|
}
|