value()); } public function text(): string { return $this->text; } public function isDecorative(): bool { return $this->decorative; } public function source(): string { return $this->source; } public function isMissing(): bool { return !$this->decorative && trim($this->text) === ''; } public function isAiGenerated(): bool { return $this->source === self::SOURCE_AI; } public function isReviewed(): bool { return $this->source === self::SOURCE_REVIEWED; } public function toArray(): array { return [ 'text' => $this->text, 'decorative' => $this->decorative, 'source' => $this->source, ]; } /** * Returns HTML attributes for the alt text. */ public function toAttr(): array { return ['alt' => $this->decorative ? '' : $this->text]; } public function toYaml(): string { return Yaml::encode($this->toArray()); } /** * Returns the resolved alt text as a Kirby Field for chaining (.or(), .isNotEmpty(), etc.) */ public function toField(): Field { return new Field(null, 'alt', (string)$this); } public function __toString(): string { if ($this->decorative) { return ''; } return $this->text; } }