DocumentStatus.php
- Pfad:
src/Domain/ValueObject/DocumentStatus.php - Namespace: Domain\ValueObject
- Zeilen: 97 | Größe: 2,177 Bytes
- Geändert: 2025-12-25 10:43:37 | 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
-
DocumentStatusenum Zeile 9
Funktionen 8
-
canTransitionTo()public Zeile 19 -
getAllowedTransitions()public Zeile 29 -
isActive()public Zeile 42 -
isTerminal()public Zeile 50 -
canReprocess()public Zeile 58 -
isSuccess()public Zeile 66 -
label()public Zeile 74 -
badgeClass()public Zeile 87
Verwendet von 2
- PipelineDocumentDTO.php use
- PipelineDocumentDTO.php constructor
Code
<?php
declare(strict_types=1);
namespace Domain\ValueObject;
// @responsibility: Document-Status-Enum für Pipeline-Verarbeitung
enum DocumentStatus: string
{
case PENDING = 'pending';
case PROCESSING = 'processing';
case DONE = 'done';
case ERROR = 'error';
/**
* 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::PENDING => [self::PROCESSING],
self::PROCESSING => [self::DONE, self::ERROR],
self::DONE => [self::PENDING],
self::ERROR => [self::PENDING],
};
}
/**
* Check if document is currently being processed.
*/
public function isActive(): bool
{
return $this === self::PROCESSING;
}
/**
* Check if this is a terminal status.
*/
public function isTerminal(): bool
{
return in_array($this, [self::DONE, self::ERROR], true);
}
/**
* Check if document can be reprocessed.
*/
public function canReprocess(): bool
{
return in_array($this, [self::DONE, self::ERROR], true);
}
/**
* Check if processing was successful.
*/
public function isSuccess(): bool
{
return $this === self::DONE;
}
/**
* Get human-readable label.
*/
public function label(): string
{
return match ($this) {
self::PENDING => 'Wartend',
self::PROCESSING => 'Verarbeitung',
self::DONE => 'Fertig',
self::ERROR => 'Fehler',
};
}
/**
* Get CSS class for badge styling.
*/
public function badgeClass(): string
{
return match ($this) {
self::PENDING => 'pending',
self::PROCESSING => 'info',
self::DONE => 'completed',
self::ERROR => 'failed',
};
}
}