tgbotlib/src/TgBotLib/Objects/Telegram/BotCommandScope/BotCommandScopeChatMember.php
Netkas 5ec6f7271a
* Renamed namespace from \TgBotLib\Abstracts to \TgBotLib\Enums
* Updated class type to `final class` in `\TgBotLib\Enums > BotCommandScopeType`
 * Updated class type to `final class` in `\TgBotLib\Enums >  ChatActionType`
 * Updated class type to `final class` in `\TgBotLib\Enums > ChatMemberStatus`
 * Updated class type to `final class` in `\TgBotLib\Enums > ChatType`
 * Updated class type to `final class` in `\TgBotLib\Enums > EventType`
 * Updated class type to `final class` in `\TgBotLib\Enums > InlineQueryResultType`
 * Updated class type to `final class` in `\TgBotLib\Enums > InputMediaType`
 * Updated class type to `final class` in `\TgBotLib\Enums > InputButtonType`
 * Updated class type to `final class` in `\TgBotLib\Enums > MessageEntityType`
 * Updated class type to `final class` in `\TgBotLib\Enums > PassportElementType`
 * Updated class type to `final class` in `\TgBotLib\Enums > PollType`
 * Updated class type to `final class` in `\TgBotLib\Enums > StickerFormat`
 * Updated class type to `final class` in `\TgBotLib\Enums > StickerType`
 * Updated class type to `final class` in `\TgBotLib\Enums > ThumbnailMimeType`
 * Updated class type to `final class` in `\TgBotLib\Enums > UpdateEventType`
2023-08-09 15:32:45 -04:00

103 lines
No EOL
2.6 KiB
PHP

<?php
/** @noinspection PhpMissingFieldTypeInspection */
namespace TgBotLib\Objects\Telegram\BotCommandScope;
use TgBotLib\Enums\BotCommandScopeType;
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\BotCommandScope;
class BotCommandScopeChatMember implements ObjectTypeInterface
{
/**
* @var string
*/
private $type;
/**
* @var string|int
*/
private $chat_id;
/**
* @var int
*/
private $user_id;
/**
* Scope type, must be chat_member
*
* @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 string|int
*/
public function getChatId(): string|int
{
return $this->chat_id;
}
/**
* Unique identifier of the target user
*
* @return int
*/
public function getUserId(): int
{
return $this->user_id;
}
/**
* Returns an array representation of the object
*
* @return array
*/
public function toArray(): array
{
return [
'type' => $this->type,
'chat_id' => $this->chat_id,
'user_id' => $this->user_id
];
}
/**
* Constructs object from an array representation
*
* @param array $data
* @return BotCommandScopeChatMember
*/
public static function fromArray(array $data): self
{
$object = new self();
$object->type = $data['type'] ?? BotCommandScopeType::CHAT_MEMBER;
$object->chat_id = $data['chat_id'] ?? null;
$object->user_id = $data['user_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();
$object->user_id = $botCommandScope->getUserId();
return $object;
}
}