name, 'preordersUsers'); } } class UserPreorderMessage implements \ArrayAccess, \JsonSerializable { use CustomDataArrayAccess; public function __construct( public string $text, public ?string $admin = null, public \DateTimeImmutable $date = new \DateTimeImmutable(), public NotifyState $notified = NotifyState::NotNotified, ) { } public static function createFromArray(array $array): UserPreorderMessage { $date = is_string($array['date'] ?? false) ? \DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, $array['date']) : new \DateTimeImmutable(); $instance = new self( text: $array['text'], admin: $array['admin'] ?? null, date: $date, notified: NotifyState::from( (int) ($array['notified'] ?? NotifyState::NotNotified->value), ), ); $instance->customData = $array['custom_data'] ?? []; return $instance; } public function jsonSerialize(): array { return [ 'text' => $this->text, 'admin' => $this->admin, 'custom_data' => $this->customData, 'date' => $this->date->format(\DateTimeInterface::ATOM), 'notified' => $this->notified->value, ]; } }