2023-02-13 20:20:29 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/** @noinspection PhpMissingFieldTypeInspection */
|
|
|
|
|
2023-02-14 17:41:38 -05:00
|
|
|
namespace TgBotLib\Objects\Telegram\BotCommandScope;
|
2023-02-13 20:20:29 -05:00
|
|
|
|
2023-08-09 15:32:45 -04:00
|
|
|
use TgBotLib\Enums\BotCommandScopeType;
|
2023-02-13 20:20:29 -05:00
|
|
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
2023-02-14 17:41:38 -05:00
|
|
|
use TgBotLib\Objects\Telegram\BotCommandScope;
|
2023-02-13 20:20:29 -05:00
|
|
|
|
|
|
|
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
|
2023-02-16 15:27:57 -05:00
|
|
|
* @return BotCommandScopeDefault
|
2023-02-13 20:20:29 -05:00
|
|
|
*/
|
2023-02-16 15:27:57 -05:00
|
|
|
public static function fromArray(array $data): self
|
2023-02-13 20:20:29 -05:00
|
|
|
{
|
|
|
|
$object = new self();
|
|
|
|
|
2023-08-09 15:32:45 -04:00
|
|
|
$object->type = $data['type'] ?? BotCommandScopeType::DEFAULT;
|
2023-02-13 20:20:29 -05:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|