46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Baselines\Compare;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
final class CompareFindingCandidate
|
|
{
|
|
/**
|
|
* @param array<string, mixed> $fingerprintBasis
|
|
* @param array<string, mixed> $evidencePayload
|
|
*/
|
|
public function __construct(
|
|
public readonly string $changeType,
|
|
public readonly string $severity,
|
|
public readonly array $fingerprintBasis,
|
|
public readonly array $evidencePayload,
|
|
public readonly bool $autoCloseEligible = true,
|
|
) {
|
|
if (trim($this->changeType) === '' || trim($this->severity) === '') {
|
|
throw new InvalidArgumentException('Compare finding candidates require non-empty change type and severity values.');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return array{
|
|
* change_type: string,
|
|
* severity: string,
|
|
* fingerprint_basis: array<string, mixed>,
|
|
* evidence_payload: array<string, mixed>,
|
|
* auto_close_eligible: bool
|
|
* }
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'change_type' => $this->changeType,
|
|
'severity' => $this->severity,
|
|
'fingerprint_basis' => $this->fingerprintBasis,
|
|
'evidence_payload' => $this->evidencePayload,
|
|
'auto_close_eligible' => $this->autoCloseEligible,
|
|
];
|
|
}
|
|
} |