type; } /** * Retrieves the date. * * @return int The date value. */ public function getDate(): int { return $this->date; } /** * @inheritDoc */ public abstract function toArray(): array; /** * @inheritDoc */ public static function fromArray(?array $data): ?MessageOrigin { if($data === null) { return null; } if(!isset($data['type'])) { throw new InvalidArgumentException('Message origin type is required'); } return match (MessageOriginType::tryFrom($data['type'])) { MessageOriginType::USER => MessageOriginUser::fromArray($data), MessageOriginType::CHAT => MessageOriginChat::fromArray($data), MessageOriginType::HIDDEN_USER => MessageOriginHiddenUser::fromArray($data), MessageOriginType::CHANNEL => MessageOriginChannel::fromArray($data), default => throw new InvalidArgumentException('Unknown message origin type'), }; } }