type; } /** * @inheritDoc */ public abstract function toArray(): array; /** * @inheritDoc */ public static function fromArray(?array $data): ?MenuButton { if($data === null) { return null; } if(!isset($data['type'])) { throw new InvalidArgumentException('MenuButton expected property type'); } return match(MenuButtonType::tryFrom($data['type'])) { MenuButtonType::COMMANDS => MenuButtonCommands::fromArray($data), MenuButtonType::DEFAULT => MenuButtonDefault::fromArray($data), MenuButtonType::WEB_APP => MenuButtonWebApp::fromArray($data), default => throw new InvalidArgumentException('Unexpected MenuButton Type') }; } }