Backup #742

ID742
Dateipfad/var/www/dev.campus.systemische-tools.de/src/UseCases/Command/UpdatePromptCommand.php
Version1
Typ modified
Größe1.4 KB
Hashb4c244bf97a38f317d155d35967baaea4885fb9f3aa28a1634eec90689d45677
Datum2025-12-23 07:58:15
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

namespace UseCases\Command;

/**
 * Command for updating an existing prompt.
 */
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