CreatePromptCommand.php
- Pfad:
src/UseCases/Command/CreatePromptCommand.php - Namespace: UseCases\Command
- Zeilen: 65 | Größe: 1,489 Bytes
- Geändert: 2025-12-27 23:17:49 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 100
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Dependencies 1
- use Domain\Constants
Klassen 1
-
CreatePromptCommandclass Zeile 11
Funktionen 4
-
__construct()public Zeile 13 -
fromRequest()public Zeile 24 -
validate()public Zeile 37 -
isValid()public Zeile 60
Verwendet von 1
Versionen 3
-
v3
2025-12-27 23:17 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v2
2025-12-27 23:17 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v1
2025-12-23 07:58 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
declare(strict_types=1);
namespace UseCases\Command;
// @responsibility: Command-Objekt für Prompt-Erstellung
use Domain\Constants;
final class CreatePromptCommand
{
public function __construct(
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(array $data): self
{
return new self(
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->name === '') {
$errors[] = 'Name ist erforderlich.';
}
if (mb_strlen($this->name) > Constants::NAME_MAX_LENGTH) {
$errors[] = 'Name darf maximal ' . Constants::NAME_MAX_LENGTH . ' Zeichen lang sein.';
}
if ($this->content === '') {
$errors[] = 'Inhalt ist erforderlich.';
}
if ($this->version === '') {
$errors[] = 'Version ist erforderlich.';
}
return $errors;
}
public function isValid(): bool
{
return $this->validate() === [];
}
}