$metadata */ public function __construct( private readonly int $id, private readonly string $uuid, private readonly int $order_id, private readonly int $snapshot_id, private readonly string $snapshot_hash, private readonly string $provider, private readonly string $document_type, private readonly ?string $external_id, private readonly ?int $issue_date, private readonly string $source_kind, private readonly ?string $storage_key, private readonly ?string $external_reference, private readonly ?string $mime_type, private readonly ?string $file_hash, private readonly ?int $file_size, private readonly string $status, private readonly string $idempotency_key, private readonly array $metadata, private readonly int $created_at ) { if ( $order_id <= 0 || $snapshot_id <= 0 || 1 !== preg_match( '/^[a-f0-9]{64}$/', $snapshot_hash ) || '' === trim( $provider ) || '' === trim( $document_type ) ) { throw new \InvalidArgumentException( 'External document identity is incomplete.' ); } if ( ! in_array( $source_kind, array( 'upload', 'reference' ), true ) || '' === $idempotency_key ) { throw new \InvalidArgumentException( 'External document source/idempotency data is invalid.' ); } if ( null !== $file_hash && 1 !== preg_match( '/^[a-f0-9]{64}$/', $file_hash ) ) { throw new \InvalidArgumentException( 'External document file hash is invalid.' ); } } public function id(): int { return $this->id; } public function uuid(): string { return $this->uuid; } public function order_id(): int { return $this->order_id; } public function snapshot_id(): int { return $this->snapshot_id; } public function snapshot_hash(): string { return $this->snapshot_hash; } public function provider(): string { return $this->provider; } public function document_type(): string { return $this->document_type; } public function external_id(): ?string { return $this->external_id; } public function issue_date(): ?int { return $this->issue_date; } public function source_kind(): string { return $this->source_kind; } public function storage_key(): ?string { return $this->storage_key; } public function external_reference(): ?string { return $this->external_reference; } public function mime_type(): ?string { return $this->mime_type; } public function file_hash(): ?string { return $this->file_hash; } public function file_size(): ?int { return $this->file_size; } public function status(): string { return $this->status; } public function idempotency_key(): string { return $this->idempotency_key; } public function metadata(): array { return $this->metadata; } public function created_at(): int { return $this->created_at; } public function customer_visible(): bool { return true === ( $this->metadata['customer_visible'] ?? false ); } }