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

55 lines
1.5 KiB
PHP
Raw Normal View History

<?php
/** @noinspection PhpMissingFieldTypeInspection */
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 BotCommandScopeAllChatAdministrators extends BotCommandScope implements ObjectTypeInterface
{
/**
* @var int|string
*/
private $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;
}
/**
* Returns an array representation of the object
*
* @return array
*/
public function toArray(): array
{
return [
2024-10-02 00:32:13 -04:00
'type' => $this->type->value,
'chat_id' => $this->chat_id
];
}
/**
* Constructs object from an array representation
*
* @param array $data
2023-02-16 15:27:57 -05:00
* @return BotCommandScopeAllChatAdministrators
*/
2024-10-02 00:32:13 -04:00
public static function fromArray(array $data): BotCommandScopeAllChatAdministrators
{
$object = new self();
2024-10-02 00:32:13 -04:00
$object->type = BotCommandScopeType::ALL_CHAT_ADMINISTRATORS;
2023-02-14 17:35:16 -05:00
$object->chat_id = $data['chat_id'] ?? null;
return $object;
}
}