Grenke Enums
app/Enums/Grenke/
Statt magischer Strings → typisierte Enums mit Verhalten.
| Enum | Werte |
|---|---|
RequestState | ReadyToSign, MissingInfo, ContractPrinted, Cancelled, Declined, RequestToGrenke, RunningContract |
ProductType | ClassicLease, … |
PaymentMethod | DirectDebit, Invoice, … |
PaymentFrequency | Monthly, Quarterly, Annually, … |
ThirdPartyIdentifierType | je nach Identifier-Art |
RequestState — die State-Machine
App\Enums\Grenke\RequestState
enum RequestState: string
{
case ReadyToSign = 'ReadyToSign';
case MissingInfo = 'MissingInfo';
case ContractPrinted = 'ContractPrinted';
case Cancelled = 'Cancelled';
case Declined = 'Declined';
case RequestToGrenke = 'RequestToGrenke';
case RunningContract = 'RunningContract';
public function isTerminal(): bool
{
return in_array($this, [
self::Cancelled, self::Declined,
self::RunningContract, self::ContractPrinted,
], true);
}
public function abortsProcess(): bool
{
return in_array($this, [self::Cancelled, self::Declined], true);
}
public function triggersMailFlow(): bool
{
return $this === self::MissingInfo;
}
public static function fromNullable(?string $value): ?self
{
return $value ? self::tryFrom($value) : null;
}
}
State-Übergangs-Diagramm
Verwendung
use App\Enums\Grenke\RequestState;
if ($request->state?->abortsProcess()) {
throw new RuntimeException('Prozess abgebrochen.');
}
if ($request->state === RequestState::ReadyToSign) {
// weiter mit e-signature
}
// String → Enum, mit Null-Toleranz
$state = RequestState::fromNullable($apiResponse['State'] ?? null);
RequestStateService::buildStateMeta()
Liefert konsistente Meta-Daten für die JSON-Response:
$this->grenkeRequestStateService->buildStateMeta($request);
// => [
// 'state' => 'ReadyToSign',
// 'is_terminal' => false,
// 'aborts_process' => false,
// 'triggers_mail_flow' => false,
// 'is_running_contract' => false,
// 'is_ready_to_sign' => true,
// ]
So sieht das Frontend immer gleichartige Felder — keine String-Vergleiche im Client.