2023-02-13 20:12:13 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
2024-10-02 00:18:12 -04:00
|
|
|
namespace TgBotLib\Objects;
|
2023-02-13 20:12:13 -05:00
|
|
|
|
|
|
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
|
|
|
|
|
|
|
class BotCommand implements ObjectTypeInterface
|
|
|
|
{
|
2024-10-04 12:07:43 -04:00
|
|
|
private string $command;
|
|
|
|
private string $description;
|
2023-02-13 20:12:13 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getCommand(): string
|
|
|
|
{
|
|
|
|
return $this->command;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Description of the command; 1-256 characters.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getDescription(): string
|
|
|
|
{
|
|
|
|
return $this->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-10-04 12:07:43 -04:00
|
|
|
* @inheritDoc
|
2023-02-13 20:12:13 -05:00
|
|
|
*/
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'command' => $this->command,
|
|
|
|
'description' => $this->description,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-10-04 12:07:43 -04:00
|
|
|
* @inheritDoc
|
2023-02-13 20:12:13 -05:00
|
|
|
*/
|
2024-10-04 12:14:32 -04:00
|
|
|
public static function fromArray(?array $data): ?BotCommand
|
2023-02-13 20:12:13 -05:00
|
|
|
{
|
2024-10-04 12:14:32 -04:00
|
|
|
if($data === null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-02-13 20:12:13 -05:00
|
|
|
$object = new self();
|
2023-02-14 17:35:16 -05:00
|
|
|
$object->command = $data['command'] ?? null;
|
|
|
|
$object->description = $data['description'] ?? null;
|
2023-02-13 20:12:13 -05:00
|
|
|
|
|
|
|
return $object;
|
|
|
|
}
|
|
|
|
}
|