type; } /** * @inheritDoc */ public abstract function toArray(): array; /** * @inheritDoc */ public static function fromArray(array $data): ObjectTypeInterface { if(!isset($data['type'])) { throw new InvalidArgumentException('BotCommandScope expected type'); } return match(BotCommandScopeType::tryFrom($data['type'])) { BotCommandScopeType::DEFAULT => BotCommandScopeDefault::fromArray($data), BotCommandScopeType::ALL_PRIVATE_CHATS => BotCommandScopeAllPrivateChats::fromArray($data), BotCommandScopeType::ALL_CHAT_GROUPS => BotCommandScopeAllGroupChats::fromArray($data), BotCommandScopeType::ALL_CHAT_ADMINISTRATORS => BotCommandScopeChatAdministrators::fromArray($data), BotCommandScopeType::CHAT => BotCommandScopeChat::fromArray($data), BotCommandScopeType::CHAT_ADMINISTRATORS => BotCommandScopeAllChatAdministrators::fromArray($data), BotCommandScopeType::CHAT_MEMBER => BotCommandScopeChatMember::fromArray($data), default => throw new InvalidArgumentException('Unexpected match value') }; } }