$data */ public static function fromRequest(int $id, array $data): self { return new self( id: $id, name: trim((string) ($data['name'] ?? '')), version: trim((string) ($data['version'] ?? '1.0')), content: trim((string) ($data['content'] ?? '')), isActive: isset($data['is_active']), ); } /** * @return array */ public function validate(): array { $errors = []; if ($this->id < 1) { $errors[] = 'Ungültige Prompt-ID.'; } if ($this->name === '') { $errors[] = 'Name ist erforderlich.'; } if (mb_strlen($this->name) > 100) { $errors[] = 'Name darf maximal 100 Zeichen lang sein.'; } if ($this->content === '') { $errors[] = 'Inhalt ist erforderlich.'; } return $errors; } public function isValid(): bool { return $this->validate() === []; } }