runs = $runs; $this->findings = $findings; $this->decisions = $decisions; $this->sanitizer = $sanitizer; } /** * @return array{decision:string,reason_masked:string,actor_role:string,decided_at:string}|null */ public function change( string $run_uuid, string $finding_uuid, string $decision, string $reason, int $actor_id ): ?array { if ( $actor_id < 1 || ! in_array( $decision, array( 'active', 'acknowledged', 'suppressed' ), true ) ) { throw new InvalidArgumentException( 'invalid_finding_decision' ); } $run = $this->runs->get_by_uuid( $run_uuid ); if ( null === $run || RunStatus::COMPLETED !== $run->status() ) { throw new StorageException( 'run_not_found' ); } $record = $this->findings->record_for_run( $run->id(), $finding_uuid ); if ( null === $record ) { throw new StorageException( 'finding_not_found' ); } if ( 'active' === $decision ) { $this->decisions->clear( $record['id'] ); return null; } $reason_masked = $this->sanitizer->sanitize( $reason ); if ( strlen( $reason_masked ) < 4 ) { throw new InvalidArgumentException( 'finding_decision_reason_required' ); } $this->decisions->save( $record['id'], $decision, $reason_masked, $actor_id, current_time( 'mysql', true ) ); $stored = $this->decisions->for_findings( array( $record['id'] ) ); return $stored[ $record['id'] ] ?? null; } }