. * * @author Daniil Gentili * @copyright 2016-2023 Daniil Gentili * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 * @link https://docs.madelineproto.xyz MadelineProto documentation */ namespace danog\MadelineProto\EventHandler; use JsonSerializable; use ReflectionClass; use ReflectionProperty; /** * Represents a bot command that can be used in a chat. */ final class Command implements JsonSerializable { /** `/command` name. */ public readonly string $command; /** Description of the command. */ public readonly string $description; /** @internal */ public function __construct(array $rawCommand) { $this->command = $rawCommand['command']; $this->description = $rawCommand['description']; } /** @internal */ public function jsonSerialize(): mixed { $res = ['_' => static::class]; $refl = new ReflectionClass($this); foreach ($refl->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) { $res[$prop->getName()] = $prop->getValue($this); } return $res; } }