*/ public function allowedTransitions(): array { return match ($this) { self::PENDING_APPROVAL => [self::APPROVED, self::REJECTED, self::CANCELLED], self::APPROVED => [self::CANCELLED, self::COMPLETED], self::REJECTED, self::CANCELLED, self::COMPLETED => [], }; } public function canTransitionTo(self $target): bool { return in_array($target, $this->allowedTransitions(), true); } public function isTerminal(): bool { return $this->allowedTransitions() === []; } }