Backup #1833

ID1833
Dateipfad/var/www/dev.campus.systemische-tools.de/src/UseCases/Command/UpdatePromptCommand.php
Version2
Typ modified
Größe1.4 KB
Hashb6e9d3f4bc3b95165f459eb14ac940b3d80823e769517f9fe2cb053282be4e60
Datum2025-12-27 23:18:35
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

declare(strict_types=1);

namespace UseCases\Command;

// @responsibility: Command-Objekt für Prompt-Aktualisierung

final class UpdatePromptCommand
{
    public function __construct(
        public readonly int $id,
        public readonly string $name,
        public readonly string $version,
        public readonly string $content,
        public readonly bool $isActive,
    ) {
    }

    /**
     * @param array<string, mixed> $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<string>
     */
    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() === [];
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
1834 3 modified 1.5 KB 2025-12-27 23:18
1833 2 modified 1.4 KB 2025-12-27 23:18
742 1 modified 1.4 KB 2025-12-23 07:58

← Zurück zur Übersicht