GenerationStatus.php
- Pfad:
src/Domain/ValueObject/GenerationStatus.php - Namespace: Domain\ValueObject
- Zeilen: 101 | Größe: 2,412 Bytes
- Geändert: 2025-12-25 10:43:10 | 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.
Klassen 1
-
GenerationStatusenum Zeile 9
Funktionen 8
-
canTransitionTo()public Zeile 20 -
getAllowedTransitions()public Zeile 30 -
isActive()public Zeile 44 -
isTerminal()public Zeile 52 -
canStart()public Zeile 60 -
canRetry()public Zeile 68 -
label()public Zeile 76 -
badgeClass()public Zeile 90
Verwendet von 2
- ContentOrderDTO.php constructor
- ContentOrderDTO.php use
Code
<?php
declare(strict_types=1);
namespace Domain\ValueObject;
// @responsibility: Generation-Status-Enum mit State-Machine für Content-Generierung
enum GenerationStatus: string
{
case IDLE = 'idle';
case QUEUED = 'queued';
case GENERATING = 'generating';
case COMPLETED = 'completed';
case FAILED = 'failed';
/**
* Check if transition to target status is allowed.
*/
public function canTransitionTo(self $target): bool
{
return in_array($target, $this->getAllowedTransitions(), true);
}
/**
* Get all allowed transitions from current status.
*
* @return array<self>
*/
public function getAllowedTransitions(): array
{
return match ($this) {
self::IDLE => [self::QUEUED],
self::QUEUED => [self::GENERATING, self::FAILED],
self::GENERATING => [self::COMPLETED, self::FAILED],
self::COMPLETED => [self::IDLE],
self::FAILED => [self::IDLE, self::QUEUED],
};
}
/**
* Check if generation is currently active.
*/
public function isActive(): bool
{
return in_array($this, [self::QUEUED, self::GENERATING], true);
}
/**
* Check if this is a terminal status.
*/
public function isTerminal(): bool
{
return in_array($this, [self::COMPLETED, self::FAILED], true);
}
/**
* Check if generation can be started.
*/
public function canStart(): bool
{
return $this === self::IDLE;
}
/**
* Check if generation can be retried.
*/
public function canRetry(): bool
{
return $this === self::FAILED;
}
/**
* Get human-readable label.
*/
public function label(): string
{
return match ($this) {
self::IDLE => 'Bereit',
self::QUEUED => 'In Warteschlange',
self::GENERATING => 'Wird generiert',
self::COMPLETED => 'Abgeschlossen',
self::FAILED => 'Fehlgeschlagen',
};
}
/**
* Get CSS class for badge styling.
*/
public function badgeClass(): string
{
return match ($this) {
self::IDLE => 'secondary',
self::QUEUED => 'pending',
self::GENERATING => 'info',
self::COMPLETED => 'completed',
self::FAILED => 'failed',
};
}
}