InvalidStateTransitionException.php
- Pfad:
src/Domain/Exception/InvalidStateTransitionException.php - Namespace: Domain\Exception
- Zeilen: 52 | Größe: 1,301 Bytes
- Geändert: 2025-12-25 11:17:31 | 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 4
- extends DomainException
- constructor BackedEnum
- use BackedEnum
- use DomainException
Klassen 1
-
InvalidStateTransitionExceptionclass Zeile 12
Funktionen 2
-
__construct()public Zeile 19 -
getAllowedValues()public Zeile 44
Versionen 1
-
v1
2025-12-23 08:07 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
declare(strict_types=1);
namespace Domain\Exception;
// @responsibility: Exception bei ungültigem Status-Übergang
use BackedEnum;
use DomainException;
final class InvalidStateTransitionException extends DomainException
{
/**
* @param BackedEnum $from Current status
* @param BackedEnum $to Target status
* @param array<BackedEnum> $allowed Allowed transitions from current status
*/
public function __construct(
public readonly BackedEnum $from,
public readonly BackedEnum $to,
public readonly array $allowed
) {
$allowedValues = array_map(
static fn (BackedEnum $s): string => (string) $s->value,
$allowed
);
$message = sprintf(
'Ungültiger Statusübergang von "%s" nach "%s". Erlaubt: %s',
$from->value,
$to->value,
$allowedValues !== [] ? implode(', ', $allowedValues) : 'keine'
);
parent::__construct($message);
}
/**
* Get allowed transition values as strings.
*
* @return array<string>
*/
public function getAllowedValues(): array
{
return array_map(
static fn (BackedEnum $s): string => (string) $s->value,
$this->allowed
);
}
}