$secondaryCauses * @param list $secondaryFacts */ public function __construct( public string $headline, public string $executionOutcomeLabel, public string $artifactImpactLabel, public string $primaryReason, public ?array $affectedScaleCue, public string $nextActionCategory, public string $nextActionText, public array $dominantCause, public array $secondaryCauses = [], public array $secondaryFacts = [], public bool $diagnosticsAvailable = false, ) { foreach ([ 'headline' => $this->headline, 'executionOutcomeLabel' => $this->executionOutcomeLabel, 'artifactImpactLabel' => $this->artifactImpactLabel, 'primaryReason' => $this->primaryReason, 'nextActionCategory' => $this->nextActionCategory, 'nextActionText' => $this->nextActionText, ] as $field => $value) { if (trim($value) === '') { throw new InvalidArgumentException("Governance run summaries require {$field}."); } } if (trim((string) ($this->dominantCause['label'] ?? '')) === '' || trim((string) ($this->dominantCause['explanation'] ?? '')) === '') { throw new InvalidArgumentException('Governance run summaries require a dominant cause label and explanation.'); } } /** * @return array{ * headline: string, * executionOutcomeLabel: string, * artifactImpactLabel: string, * primaryReason: string, * affectedScaleCue: array{label: string, value: string, source: string, confidence?: string}|null, * nextActionCategory: string, * nextActionText: string, * dominantCause: array{code: ?string, label: string, explanation: string}, * secondaryCauses: list, * secondaryFacts: list, * diagnosticsAvailable: bool * } */ public function toArray(): array { return [ 'headline' => $this->headline, 'executionOutcomeLabel' => $this->executionOutcomeLabel, 'artifactImpactLabel' => $this->artifactImpactLabel, 'primaryReason' => $this->primaryReason, 'affectedScaleCue' => $this->affectedScaleCue, 'nextActionCategory' => $this->nextActionCategory, 'nextActionText' => $this->nextActionText, 'dominantCause' => $this->dominantCause, 'secondaryCauses' => $this->secondaryCauses, 'secondaryFacts' => $this->secondaryFacts, 'diagnosticsAvailable' => $this->diagnosticsAvailable, ]; } }