state = $state; $this->findings = $findings; $this->next_polling_delay = max( 0, min( 300, $next_polling_delay ) ); } /** @param array $payload API or local option boundary payload. */ public static function from_payload( array $payload ): ?self { $state = RunStatus::from_payload( $payload ); $findings = RunFindings::from_payload( $payload ); $delay = $payload['next_polling_delay_seconds'] ?? null; if ( ! $state instanceof RunStatus || ! $findings instanceof RunFindings || ! is_int( $delay ) ) { return null; } return new self( $state, $findings, $delay ); } public function is_terminal(): bool { return in_array( $this->state->status, array( 'completed', 'partially_completed', 'failed' ), true ); } /** @return array Local option boundary payload. */ public function to_payload(): array { return array_merge( $this->state->to_payload(), $this->findings->to_payload(), array( 'next_polling_delay_seconds' => $this->next_polling_delay ) ); } }