$meta reine Anzeigetexte aus Fachdaten * @param list $missing Hinweise für die Redaktion */ public function __construct( public string $title, public ?string $summary, public string $kind, public ?string $badge, public array $meta, public ?string $url, public bool $public, public ?string $notice = null, public ?string $visual = null, public ?string $visualLabel = null, public ?string $previewImage = null, public array $missing = [], public ?string $style = null, public array $texts = [], ) {} public function withText(?string $title, ?string $summary): self { return $this->copy(['title' => $title ?? $this->title, 'summary' => $summary ?? $this->summary]); } /** * Text der Karte aus einem zentralen Text des Fachobjekts. Ist er nicht gepflegt, bleibt die Karte ohne Text * (kein stiller Ersatz aus einem anderen Feld); in der Redaktionsvorschau steht dann ein Hinweis. */ public function withTextChoice(string $field, string $missingHint): self { if (! array_key_exists($field, $this->texts)) { return $this; } $text = $this->texts[$field]; $missing = array_values(array_filter($this->missing, fn (string $hint): bool => ! str_contains($hint, 'Kurzbeschreibung'))); if ($text === null) { $missing[] = $missingHint; } return $this->copy(['summary' => $text, 'missing' => $missing]); } /** * @param array $changes */ private function copy(array $changes): self { return new self(...array_merge(get_object_vars($this), $changes)); } }