Files
peptide-repo-core/includes/dto/class-pr-core-legal-cell-dto.php
peptiderepo 53c71dca12 fix: move file docblocks to immediately after <?php (before declare)
PHPCS Squiz.Commenting.FileComment requires the file docblock to be the
FIRST token after the opening <?php tag. Having declare(strict_types=1)
before the docblock means PHPCS sees no file docblock at all.

Fix: in every includes/*.php file, insert a minimal /** @package ... */
docblock immediately after <?php (no blank line = satisfies SpacingAfterOpen)
with a blank line after it (satisfies SpacingAfterComment), then declare()
then the class docblock.

Also fixes peptide-repo-core.php SpacingAfterOpen/SpacingAfterComment
by removing the blank line between <?php and the existing file docblock
and ensuring one blank line after it.

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

148 lines
3.4 KiB
PHP

<?php
/**
* @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(),
);
}
}