tgbotlib/src/TgBotLib/Objects/Telegram/BotCommandScope/BotCommandScopeAllGroupChats.php

69 lines
1.7 KiB
PHP
Raw Normal View History

<?php
/** @noinspection PhpMissingFieldTypeInspection */
2023-02-14 17:41:38 -05:00
namespace TgBotLib\Objects\Telegram\BotCommandScope;
use TgBotLib\Enums\BotCommandScopeType;
use TgBotLib\Interfaces\ObjectTypeInterface;
2023-02-14 17:41:38 -05:00
use TgBotLib\Objects\Telegram\BotCommandScope;
class BotCommandScopeAllGroupChats implements ObjectTypeInterface
{
/**
* @var string
*/
private $type;
/**
* Scope type, must be all_group_chats
*
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* Returns an array representation of the object
*
* @return array
*/
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 BotCommandScopeAllGroupChats
*/
2023-02-16 15:27:57 -05:00
public static function fromArray(array $data): self
{
$object = new self();
$object->type = $data['type'] ?? BotCommandScopeType::ALL_CHAT_GROUPS;
return $object;
}
2023-02-13 20:33:55 -05:00
/**
* Constructs object from BotCommandScope
*
* @param BotCommandScope $botCommandScope
* @return BotCommandScopeAllGroupChats
*/
public static function fromBotCommandScope(BotCommandScope $botCommandScope): BotCommandScopeAllGroupChats
{
$object = new self();
$object->type = $botCommandScope->getType();
return $object;
}
}