Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
31 / 31 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| InvestorDocumentData | |
100.00% |
31 / 31 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fromRow | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Domain\Document\Submission\Data; |
| 6 | |
| 7 | use App\Support\Row; |
| 8 | |
| 9 | /** |
| 10 | * Investor-submitted document workflow row. |
| 11 | * |
| 12 | * Combines the parent investor_uploaded_documents row with denormalised |
| 13 | * "current state" fields drawn from the latest matching events: |
| 14 | * - currentFile* — from the most recent event_type='uploaded' event |
| 15 | * - latestNote — from the most recent event_type='rejected' event |
| 16 | * |
| 17 | * The repository is responsible for providing those derived columns; |
| 18 | * this DTO just narrows them. |
| 19 | */ |
| 20 | final readonly class InvestorDocumentData |
| 21 | { |
| 22 | public function __construct( |
| 23 | public int $documentId, |
| 24 | public int $investorId, |
| 25 | public int $documentTypeId, |
| 26 | public string $documentTypeCode, |
| 27 | public string $documentTypeLabel, |
| 28 | public string $status, |
| 29 | public string $createdAt, |
| 30 | public string $updatedAt, |
| 31 | public ?string $currentFilename, |
| 32 | public ?string $currentMimeType, |
| 33 | public ?int $currentSizeBytes, |
| 34 | public ?string $currentUploadedAt, |
| 35 | public ?string $latestNote, |
| 36 | ) {} |
| 37 | |
| 38 | /** |
| 39 | * @param array<mixed> $row |
| 40 | */ |
| 41 | public static function fromRow(array $row): self |
| 42 | { |
| 43 | return new self( |
| 44 | documentId: Row::int($row, 'documentId'), |
| 45 | investorId: Row::int($row, 'investorId'), |
| 46 | documentTypeId: Row::int($row, 'documentTypeId'), |
| 47 | documentTypeCode: Row::string($row, 'documentTypeCode'), |
| 48 | documentTypeLabel: Row::string($row, 'documentTypeLabel'), |
| 49 | status: Row::string($row, 'status'), |
| 50 | createdAt: Row::string($row, 'createdAt'), |
| 51 | updatedAt: Row::string($row, 'updatedAt'), |
| 52 | currentFilename: Row::nullableString($row, 'currentFilename'), |
| 53 | currentMimeType: Row::nullableString($row, 'currentMimeType'), |
| 54 | currentSizeBytes: Row::nullableInt($row, 'currentSizeBytes'), |
| 55 | currentUploadedAt: Row::nullableString($row, 'currentUploadedAt'), |
| 56 | latestNote: Row::nullableString($row, 'latestNote'), |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * @return array<string, mixed> |
| 62 | */ |
| 63 | public function toArray(): array |
| 64 | { |
| 65 | return [ |
| 66 | 'documentId' => $this->documentId, |
| 67 | 'investorId' => $this->investorId, |
| 68 | 'documentTypeId' => $this->documentTypeId, |
| 69 | 'documentTypeCode' => $this->documentTypeCode, |
| 70 | 'documentTypeLabel' => $this->documentTypeLabel, |
| 71 | 'status' => $this->status, |
| 72 | 'createdAt' => $this->createdAt, |
| 73 | 'updatedAt' => $this->updatedAt, |
| 74 | 'currentFilename' => $this->currentFilename, |
| 75 | 'currentMimeType' => $this->currentMimeType, |
| 76 | 'currentSizeBytes' => $this->currentSizeBytes, |
| 77 | 'currentUploadedAt' => $this->currentUploadedAt, |
| 78 | 'latestNote' => $this->latestNote, |
| 79 | ]; |
| 80 | } |
| 81 | } |