Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
35 / 35
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
AdminInvestorDocumentData
100.00% covered (success)
100.00%
35 / 35
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 fromRow
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\Document\Submission\Data;
6
7use App\Support\Row;
8
9/**
10 * Admin-side view of an investor-submitted document.
11 *
12 * Mirrors {@see InvestorDocumentData} and adds investor name + email
13 * so the admin queue and detail surfaces don't need a second lookup
14 * per row. Kept distinct from the investor-facing DTO so the audience
15 * for each shape stays explicit.
16 */
17final readonly class AdminInvestorDocumentData
18{
19    public function __construct(
20        public int $documentId,
21        public int $investorId,
22        public string $investorName,
23        public string $investorEmail,
24        public int $documentTypeId,
25        public string $documentTypeCode,
26        public string $documentTypeLabel,
27        public string $status,
28        public string $createdAt,
29        public string $updatedAt,
30        public ?string $currentFilename,
31        public ?string $currentMimeType,
32        public ?int $currentSizeBytes,
33        public ?string $currentUploadedAt,
34        public ?string $latestNote,
35    ) {}
36
37    /**
38     * @param array<mixed> $row
39     */
40    public static function fromRow(array $row): self
41    {
42        return new self(
43            documentId: Row::int($row, 'documentId'),
44            investorId: Row::int($row, 'investorId'),
45            investorName: Row::string($row, 'investorName'),
46            investorEmail: Row::string($row, 'investorEmail'),
47            documentTypeId: Row::int($row, 'documentTypeId'),
48            documentTypeCode: Row::string($row, 'documentTypeCode'),
49            documentTypeLabel: Row::string($row, 'documentTypeLabel'),
50            status: Row::string($row, 'status'),
51            createdAt: Row::string($row, 'createdAt'),
52            updatedAt: Row::string($row, 'updatedAt'),
53            currentFilename: Row::nullableString($row, 'currentFilename'),
54            currentMimeType: Row::nullableString($row, 'currentMimeType'),
55            currentSizeBytes: Row::nullableInt($row, 'currentSizeBytes'),
56            currentUploadedAt: Row::nullableString($row, 'currentUploadedAt'),
57            latestNote: Row::nullableString($row, 'latestNote'),
58        );
59    }
60
61    /**
62     * @return array<string, mixed>
63     */
64    public function toArray(): array
65    {
66        return [
67            'documentId' => $this->documentId,
68            'investorId' => $this->investorId,
69            'investorName' => $this->investorName,
70            'investorEmail' => $this->investorEmail,
71            'documentTypeId' => $this->documentTypeId,
72            'documentTypeCode' => $this->documentTypeCode,
73            'documentTypeLabel' => $this->documentTypeLabel,
74            'status' => $this->status,
75            'createdAt' => $this->createdAt,
76            'updatedAt' => $this->updatedAt,
77            'currentFilename' => $this->currentFilename,
78            'currentMimeType' => $this->currentMimeType,
79            'currentSizeBytes' => $this->currentSizeBytes,
80            'currentUploadedAt' => $this->currentUploadedAt,
81            'latestNote' => $this->latestNote,
82        ];
83    }
84}