65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\RestoreSafety;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
final readonly class RestoreResultAttention
|
|
{
|
|
public const string STATE_NOT_EXECUTED = 'not_executed';
|
|
|
|
public const string STATE_COMPLETED = 'completed';
|
|
|
|
public const string STATE_PARTIAL = 'partial';
|
|
|
|
public const string STATE_FAILED = 'failed';
|
|
|
|
public const string STATE_COMPLETED_WITH_FOLLOW_UP = 'completed_with_follow_up';
|
|
|
|
public function __construct(
|
|
public string $state,
|
|
public bool $followUpRequired,
|
|
public string $primaryCauseFamily,
|
|
public string $summary,
|
|
public string $primaryNextAction,
|
|
public string $recoveryClaimBoundary,
|
|
public string $tone,
|
|
) {
|
|
if (! in_array($this->state, [
|
|
self::STATE_NOT_EXECUTED,
|
|
self::STATE_COMPLETED,
|
|
self::STATE_PARTIAL,
|
|
self::STATE_FAILED,
|
|
self::STATE_COMPLETED_WITH_FOLLOW_UP,
|
|
], true)) {
|
|
throw new InvalidArgumentException('Unsupported restore result attention state.');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return array{
|
|
* state: string,
|
|
* follow_up_required: bool,
|
|
* primary_cause_family: string,
|
|
* summary: string,
|
|
* primary_next_action: string,
|
|
* recovery_claim_boundary: string,
|
|
* tone: string
|
|
* }
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'state' => $this->state,
|
|
'follow_up_required' => $this->followUpRequired,
|
|
'primary_cause_family' => $this->primaryCauseFamily,
|
|
'summary' => $this->summary,
|
|
'primary_next_action' => $this->primaryNextAction,
|
|
'recovery_claim_boundary' => $this->recoveryClaimBoundary,
|
|
'tone' => $this->tone,
|
|
];
|
|
}
|
|
}
|