Squash-merge of PR #22: adopt shared reusable CI workflow, convert PHPUnit to stubs, update branch-protection contexts.
QA-approved at 05d8094a1d. All required CI checks green.
Agent-Session: 2026-06-17-prcore-ci-deploy
150 lines
3.4 KiB
PHP
150 lines
3.4 KiB
PHP
<?php
|
|
/**
|
|
* Legal Cell Dto.
|
|
*
|
|
* @package Peptide_Repo_Core
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Immutable value object wrapping a row from pr_legal_cells
|
|
*
|
|
* @package Peptide_Repo_Core
|
|
*/
|
|
|
|
/**
|
|
* Typed data-transfer object for a legal status cell.
|
|
*
|
|
* What: Immutable value object wrapping a row from pr_legal_cells.
|
|
* Who calls it: PR_Core_Legal_Repository returns these; consumers read them.
|
|
* Dependencies: None.
|
|
*
|
|
* @see migrations/class-pr-core-migration-0002-legal-cells.php — Table schema.
|
|
* @see repositories/class-pr-core-legal-repository.php — Creates these from DB rows.
|
|
*/
|
|
class PR_Core_Legal_Cell_DTO {
|
|
|
|
/**
|
|
* Int.
|
|
*
|
|
* @var int
|
|
*/
|
|
public readonly int $id;
|
|
/**
|
|
* Int.
|
|
*
|
|
* @var int
|
|
*/
|
|
public readonly int $peptide_id;
|
|
/**
|
|
* String.
|
|
*
|
|
* @var string
|
|
*/
|
|
public readonly string $country_code;
|
|
/**
|
|
* String.
|
|
*
|
|
* @var string
|
|
*/
|
|
public readonly string $status;
|
|
/**
|
|
* ?string.
|
|
*
|
|
* @var ?string
|
|
*/
|
|
public readonly ?string $regulatory_framework;
|
|
/**
|
|
* ?string.
|
|
*
|
|
* @var ?string
|
|
*/
|
|
public readonly ?string $regulatory_text_url;
|
|
/**
|
|
* ?string.
|
|
*
|
|
* @var ?string
|
|
*/
|
|
public readonly ?string $regulatory_text_quote;
|
|
/**
|
|
* ?string.
|
|
*
|
|
* @var ?string
|
|
*/
|
|
public readonly ?string $notes;
|
|
/**
|
|
* String.
|
|
*
|
|
* @var string
|
|
*/
|
|
public readonly string $last_verified_at;
|
|
/**
|
|
* Int.
|
|
*
|
|
* @var int
|
|
*/
|
|
public readonly int $schema_version;
|
|
/**
|
|
* Int.
|
|
*
|
|
* @var int
|
|
*/
|
|
public readonly int $reviewer_id;
|
|
/**
|
|
* ?int.
|
|
*
|
|
* @var ?int
|
|
*/
|
|
public readonly ?int $superseded_by_id;
|
|
|
|
/**
|
|
* Construct.
|
|
*
|
|
* @param array<string, mixed> $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<string, mixed>
|
|
*/
|
|
public function to_array(): array {
|
|
return array(
|
|
'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(),
|
|
);
|
|
}
|
|
}
|