tgbotlib/src/TgBotLib/Objects/Telegram/BotCommandScope/BotCommandScopeDefault.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

69 lines
No EOL
1.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 BotCommandScopeDefault implements ObjectTypeInterface
{
/**
* @var string
*/
private $type;
/**
* Scope type, must be default
*
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* Returns an array representation of the object
*
* @return string[]
*/
public function toArray(): array
{
return [
'type' => $this->type
];
}
/**
* Constructs object from an array representation
*
* @param array $data
* @return BotCommandScopeDefault
*/
public static function fromArray(array $data): self
{
$object = new self();
$object->type = $data['type'] ?? BotCommandScopeType::DEFAULT;
return $object;
}
/**
* Constructs object from BotCommandScope
*
* @param BotCommandScope $botCommandScope
* @return BotCommandScopeDefault
*/
public static function fromBotCommandScope(BotCommandScope $botCommandScope): BotCommandScopeDefault
{
$object = new self();
$object->type = $botCommandScope->getType();
return $object;
}
}