Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
26 / 26 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| InvestorDocumentEventData | |
100.00% |
26 / 26 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fromRow | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
11 / 11 |
|
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 | * One row from investor_uploaded_document_events. |
| 11 | * |
| 12 | * Append-only history. The newest event of a given type wins: |
| 13 | * - latest 'uploaded' event = the current file |
| 14 | * - latest 'rejected' event = the current admin note |
| 15 | */ |
| 16 | final readonly class InvestorDocumentEventData |
| 17 | { |
| 18 | public function __construct( |
| 19 | public int $eventId, |
| 20 | public int $documentId, |
| 21 | public string $eventType, |
| 22 | public ?string $fileStorageKey, |
| 23 | public ?string $originalFilename, |
| 24 | public ?string $mimeType, |
| 25 | public ?int $sizeBytes, |
| 26 | public ?string $sha256, |
| 27 | public ?string $notes, |
| 28 | public ?int $actorUserId, |
| 29 | public string $actorType, |
| 30 | public string $createdAt, |
| 31 | ) {} |
| 32 | |
| 33 | /** |
| 34 | * @param array<mixed> $row |
| 35 | */ |
| 36 | public static function fromRow(array $row): self |
| 37 | { |
| 38 | return new self( |
| 39 | eventId: Row::int($row, 'eventId'), |
| 40 | documentId: Row::int($row, 'documentId'), |
| 41 | eventType: Row::string($row, 'eventType'), |
| 42 | fileStorageKey: Row::nullableString($row, 'fileStorageKey'), |
| 43 | originalFilename: Row::nullableString($row, 'originalFilename'), |
| 44 | mimeType: Row::nullableString($row, 'mimeType'), |
| 45 | sizeBytes: Row::nullableInt($row, 'sizeBytes'), |
| 46 | sha256: Row::nullableString($row, 'sha256'), |
| 47 | notes: Row::nullableString($row, 'notes'), |
| 48 | actorUserId: Row::nullableInt($row, 'actorUserId'), |
| 49 | actorType: Row::string($row, 'actorType'), |
| 50 | createdAt: Row::string($row, 'createdAt'), |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @return array<string, mixed> |
| 56 | */ |
| 57 | public function toArray(): array |
| 58 | { |
| 59 | return [ |
| 60 | 'eventId' => $this->eventId, |
| 61 | 'documentId' => $this->documentId, |
| 62 | 'eventType' => $this->eventType, |
| 63 | 'originalFilename' => $this->originalFilename, |
| 64 | 'mimeType' => $this->mimeType, |
| 65 | 'sizeBytes' => $this->sizeBytes, |
| 66 | 'notes' => $this->notes, |
| 67 | 'actorType' => $this->actorType, |
| 68 | 'createdAt' => $this->createdAt, |
| 69 | ]; |
| 70 | } |
| 71 | } |