id = (int) ( $data['id'] ?? 0 ); $this->analysis_type = $data['analysis_type']; $this->topic = $data['topic']; $this->summary = $data['summary'] ?? null; $this->frequency = (int) ( $data['frequency'] ?? 1 ); $this->relevance_score = (float) ( $data['relevance_score'] ?? 0.0 ); $this->source_ids = $data['source_ids'] ?? []; $this->analyzed_at = $data['analyzed_at'] ?? current_time( 'mysql' ); $this->metadata = $data['metadata'] ?? null; } public function get_id(): int { return $this->id; } public function get_analysis_type(): string { return $this->analysis_type; } public function get_topic(): string { return $this->topic; } public function get_summary(): ?string { return $this->summary; } public function get_frequency(): int { return $this->frequency; } public function get_relevance_score(): float { return $this->relevance_score; } public function get_source_ids(): array { return $this->source_ids; } public function get_analyzed_at(): string { return $this->analyzed_at; } public function get_metadata(): ?array { return $this->metadata; } /** * @return array */ public function to_db_row(): array { return [ 'analysis_type' => $this->analysis_type, 'topic' => $this->topic, 'summary' => $this->summary, 'frequency' => $this->frequency, 'relevance_score' => $this->relevance_score, 'source_ids_json' => wp_json_encode( $this->source_ids ), 'analyzed_at' => $this->analyzed_at, 'metadata_json' => null !== $this->metadata ? wp_json_encode( $this->metadata ) : null, ]; } }