Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
25 / 25 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| ProvidedDocumentData | |
100.00% |
25 / 25 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fromRow | |
100.00% |
13 / 13 |
|
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\Provided\Data; |
| 6 | |
| 7 | use App\Support\Row; |
| 8 | |
| 9 | /** |
| 10 | * A document an admin has provided to an investor (FSC-57). |
| 11 | * |
| 12 | * fileStorageKey/sha256 are carried for download + integrity but never |
| 13 | * leave the backend — {@see toArray()} omits them. |
| 14 | */ |
| 15 | final readonly class ProvidedDocumentData |
| 16 | { |
| 17 | public function __construct( |
| 18 | public int $providedDocumentId, |
| 19 | public int $investorId, |
| 20 | public string $title, |
| 21 | public ?string $description, |
| 22 | public string $fileStorageKey, |
| 23 | public string $originalFilename, |
| 24 | public string $mimeType, |
| 25 | public int $sizeBytes, |
| 26 | public string $sha256, |
| 27 | public ?string $uploadedByName, |
| 28 | public string $createdAt, |
| 29 | ) {} |
| 30 | |
| 31 | /** |
| 32 | * @param array<mixed> $row |
| 33 | */ |
| 34 | public static function fromRow(array $row): self |
| 35 | { |
| 36 | return new self( |
| 37 | providedDocumentId: Row::int($row, 'providedDocumentId'), |
| 38 | investorId: Row::int($row, 'investorId'), |
| 39 | title: Row::string($row, 'title'), |
| 40 | description: Row::nullableString($row, 'description'), |
| 41 | fileStorageKey: Row::string($row, 'fileStorageKey'), |
| 42 | originalFilename: Row::string($row, 'originalFilename'), |
| 43 | mimeType: Row::string($row, 'mimeType'), |
| 44 | sizeBytes: Row::int($row, 'sizeBytes'), |
| 45 | sha256: Row::string($row, 'sha256'), |
| 46 | uploadedByName: Row::nullableString($row, 'uploadedByName'), |
| 47 | createdAt: Row::string($row, 'createdAt'), |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @return array<string, mixed> |
| 53 | */ |
| 54 | public function toArray(): array |
| 55 | { |
| 56 | return [ |
| 57 | 'providedDocumentId' => $this->providedDocumentId, |
| 58 | 'investorId' => $this->investorId, |
| 59 | 'title' => $this->title, |
| 60 | 'description' => $this->description, |
| 61 | 'originalFilename' => $this->originalFilename, |
| 62 | 'mimeType' => $this->mimeType, |
| 63 | 'sizeBytes' => $this->sizeBytes, |
| 64 | 'uploadedByName' => $this->uploadedByName, |
| 65 | 'createdAt' => $this->createdAt, |
| 66 | ]; |
| 67 | } |
| 68 | } |