$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 */ public function getAllowedValues(): array { return array_map( static fn (BackedEnum $s): string => (string) $s->value, $this->allowed ); } }