71 lines
2.3 KiB
PHP
71 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Providers\Capabilities;
|
|
|
|
final readonly class ProviderCapabilityResult
|
|
{
|
|
/**
|
|
* @param array<int, string> $providerRequirementKeys
|
|
* @param array<int, string> $missingRequirementKeys
|
|
* @param array<string, int> $evidenceCounts
|
|
*/
|
|
public function __construct(
|
|
public string $key,
|
|
public string $label,
|
|
public ProviderCapabilityStatus $status,
|
|
public ?string $reasonCode = null,
|
|
public array $providerRequirementKeys = [],
|
|
public array $missingRequirementKeys = [],
|
|
public ?string $lastCheckedAt = null,
|
|
public ?string $primaryMessage = null,
|
|
public ?string $providerHint = null,
|
|
public array $evidenceCounts = [],
|
|
public ?string $nextStepLabel = null,
|
|
public ?string $nextStepUrl = null,
|
|
) {}
|
|
|
|
public function blocksExecution(): bool
|
|
{
|
|
return $this->status->blocksExecution();
|
|
}
|
|
|
|
/**
|
|
* @return array{
|
|
* provider_capability_key: string,
|
|
* label: string,
|
|
* status: string,
|
|
* reason_code: ?string,
|
|
* provider_requirement_keys: array<int, string>,
|
|
* missing_requirement_keys: array<int, string>,
|
|
* last_checked_at: ?string,
|
|
* primary_message: ?string,
|
|
* provider_hint: ?string,
|
|
* evidence_counts: array<string, int>,
|
|
* next_step: array{label: ?string, url: ?string},
|
|
* blocks_execution: bool
|
|
* }
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'provider_capability_key' => $this->key,
|
|
'label' => $this->label,
|
|
'status' => $this->status->value,
|
|
'reason_code' => $this->reasonCode,
|
|
'provider_requirement_keys' => $this->providerRequirementKeys,
|
|
'missing_requirement_keys' => $this->missingRequirementKeys,
|
|
'last_checked_at' => $this->lastCheckedAt,
|
|
'primary_message' => $this->primaryMessage,
|
|
'provider_hint' => $this->providerHint,
|
|
'evidence_counts' => $this->evidenceCounts,
|
|
'next_step' => [
|
|
'label' => $this->nextStepLabel,
|
|
'url' => $this->nextStepUrl,
|
|
],
|
|
'blocks_execution' => $this->blocksExecution(),
|
|
];
|
|
}
|
|
}
|