Files
peptide-repo-core/includes/dto/class-pr-core-legal-cell-dto.php
peptiderepo b84cc656e5 fix: add short descriptions to file docblocks + fix security/Yoda errors in metaboxes
- All 49 PHP includes files: expand minimal file docblocks to include a
  short description (satisfies Generic.Commenting.DocComment.MissingShort)
  Format: <?php\n/**\n * Filename-derived description.\n *\n * @package ...\n */
- settings.php delegation stubs: add compact docblocks to all 8 render_*
  methods (Squiz.Commenting.FunctionComment.Missing, lines 93-231)
- settings.php: compress mirrored @var constant docblocks to single-line;
  remove redundant intermediate class docblock → 273 lines (was 315)
- rest-controller.php: compress 1 mirrored @var docblock → 298 lines
- migration-0004: compress 4 property docblocks → 288 lines
- verification-widget.php line 111: cast days_since to int + phpcs:ignore
- verification-metabox.php line 80: phpcs:ignore on hardcoded badge_class
- peptide-metaboxes.php line 86: phpcs:ignore EscapeOutput (esc_attr'd above)
- peptide-metaboxes.php lines 147/148: Yoda null !== dose_min/dose_max
- peptide-metaboxes.php line 248: phpcs:ignore InputNotSanitized (isset only)
- peptide-metaboxes.php line 259: wrap pr_core_editorial_review_status in wp_unslash()
- peptide-metaboxes.php line 262: Yoda 'published' !== old_status

Agent-Session: claude-adopt-ci-20260616
2026-06-16 16:12:25 +00:00

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(),
);
}
}