$data Associative array from database row. */ public function __construct( array $data ) { $this->id = (int) ( $data['id'] ?? 0 ); $this->peptide_id = (int) ( $data['peptide_id'] ?? 0 ); $this->country_code = (string) ( $data['country_code'] ?? '' ); $this->status = (string) ( $data['status'] ?? 'unclear' ); $this->regulatory_framework = $data['regulatory_framework'] ?? null; $this->regulatory_text_url = $data['regulatory_text_url'] ?? null; $this->regulatory_text_quote = $data['regulatory_text_quote'] ?? null; $this->notes = $data['notes'] ?? null; $this->last_verified_at = (string) ( $data['last_verified_at'] ?? '' ); $this->schema_version = (int) ( $data['schema_version'] ?? 1 ); $this->reviewer_id = (int) ( $data['reviewer_id'] ?? 0 ); $this->superseded_by_id = isset( $data['superseded_by_id'] ) ? (int) $data['superseded_by_id'] : null; } /** * Check if this cell is the active (non-superseded) version. * * @return bool */ public function is_active(): bool { return null === $this->superseded_by_id; } /** * Convert to associative array for REST/admin output. * * @return array */ public function to_array(): array { return [ 'id' => $this->id, 'peptide_id' => $this->peptide_id, 'country_code' => $this->country_code, 'status' => $this->status, 'regulatory_framework' => $this->regulatory_framework, 'regulatory_text_url' => $this->regulatory_text_url, 'regulatory_text_quote' => $this->regulatory_text_quote, 'notes' => $this->notes, 'last_verified_at' => $this->last_verified_at, 'is_active' => $this->is_active(), ]; } }