Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
41.18% |
14 / 34 |
|
50.00% |
2 / 4 |
CRAP | |
0.00% |
0 / 1 |
| FundingRequestData | |
41.18% |
14 / 34 |
|
50.00% |
2 / 4 |
7.26 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fromRow | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| toAdminArray | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Domain\Funding\Data; |
| 6 | |
| 7 | use App\Support\Row; |
| 8 | |
| 9 | /** |
| 10 | * An investor-initiated deposit or withdrawal request (FSC-21). |
| 11 | */ |
| 12 | final readonly class FundingRequestData |
| 13 | { |
| 14 | public function __construct( |
| 15 | public ?int $fundingRequestId = null, |
| 16 | public ?int $investorId = null, |
| 17 | public ?int $accountId = null, |
| 18 | public ?string $requestType = null, |
| 19 | public ?string $amount = null, |
| 20 | public ?string $note = null, |
| 21 | public ?string $status = null, |
| 22 | public ?string $createdAt = null, |
| 23 | // Populated only by the admin-queue queries (investor join + review fields). |
| 24 | public ?string $investorName = null, |
| 25 | public ?string $investorEmail = null, |
| 26 | public ?string $reviewedAt = null, |
| 27 | ) {} |
| 28 | |
| 29 | /** |
| 30 | * @param array<mixed> $row |
| 31 | */ |
| 32 | public static function fromRow(array $row): self |
| 33 | { |
| 34 | return new self( |
| 35 | fundingRequestId: Row::nullableInt($row, 'fundingRequestId'), |
| 36 | investorId: Row::nullableInt($row, 'investorId'), |
| 37 | accountId: Row::nullableInt($row, 'accountId'), |
| 38 | requestType: Row::nullableString($row, 'requestType'), |
| 39 | amount: Row::nullableString($row, 'amount'), |
| 40 | note: Row::nullableString($row, 'note'), |
| 41 | status: Row::nullableString($row, 'status'), |
| 42 | createdAt: Row::nullableString($row, 'createdAt'), |
| 43 | investorName: Row::nullableString($row, 'investorName'), |
| 44 | investorEmail: Row::nullableString($row, 'investorEmail'), |
| 45 | reviewedAt: Row::nullableString($row, 'reviewedAt'), |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Investor-facing shape (the submitter already knows who they are). |
| 51 | * |
| 52 | * @return array<string, mixed> |
| 53 | */ |
| 54 | public function toArray(): array |
| 55 | { |
| 56 | return [ |
| 57 | 'fundingRequestId' => $this->fundingRequestId, |
| 58 | 'requestType' => $this->requestType, |
| 59 | 'amount' => $this->amount, |
| 60 | 'note' => $this->note, |
| 61 | 'status' => $this->status, |
| 62 | 'createdAt' => $this->createdAt, |
| 63 | ]; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Admin-queue shape — adds the investor identity and review timestamp the |
| 68 | * admin needs to action the request. |
| 69 | * |
| 70 | * @return array<string, mixed> |
| 71 | */ |
| 72 | public function toAdminArray(): array |
| 73 | { |
| 74 | return [ |
| 75 | 'fundingRequestId' => $this->fundingRequestId, |
| 76 | 'investorId' => $this->investorId, |
| 77 | 'investorName' => $this->investorName, |
| 78 | 'investorEmail' => $this->investorEmail, |
| 79 | 'requestType' => $this->requestType, |
| 80 | 'amount' => $this->amount, |
| 81 | 'note' => $this->note, |
| 82 | 'status' => $this->status, |
| 83 | 'createdAt' => $this->createdAt, |
| 84 | 'reviewedAt' => $this->reviewedAt, |
| 85 | ]; |
| 86 | } |
| 87 | } |