tgbotlib/src/TgBotLib/Objects/BotCommandScope/BotCommandScopeChat.php

54 lines
1.3 KiB
PHP
Raw Normal View History

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