Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
93.75% |
15 / 16 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| AccountSummaryData | |
93.75% |
15 / 16 |
|
50.00% |
1 / 2 |
2.00 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
1 | |||
| jsonSerialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Domain\Account\Data; |
| 6 | |
| 7 | use App\Support\Row; |
| 8 | use JsonSerializable; |
| 9 | |
| 10 | /** |
| 11 | * Data transfer object for account summary information. |
| 12 | * |
| 13 | * All properties use camelCase. Repository handles snake_case conversion. |
| 14 | * |
| 15 | * All monetary values and ratios are stored as strings to preserve |
| 16 | * exact decimal precision from PostgreSQL NUMERIC types. |
| 17 | */ |
| 18 | final class AccountSummaryData implements JsonSerializable |
| 19 | { |
| 20 | public int $accountId; |
| 21 | |
| 22 | public int $investorId; |
| 23 | |
| 24 | public string $accountNumber; |
| 25 | |
| 26 | public string $balance; |
| 27 | |
| 28 | public string $availableBalance; |
| 29 | |
| 30 | public string $availableForLoan; |
| 31 | |
| 32 | public string $maxLoanAmount; |
| 33 | |
| 34 | public string $totalOutstandingLoans; |
| 35 | |
| 36 | public string $earningsYtd; |
| 37 | public string $interestRate; |
| 38 | |
| 39 | public string $loanToValueRatio; |
| 40 | |
| 41 | public string $loanInterestRate; |
| 42 | public string $status; |
| 43 | |
| 44 | public bool $hasAvailableCredit; |
| 45 | |
| 46 | public bool $hasActiveLoans; |
| 47 | |
| 48 | /** |
| 49 | * @param array<mixed> $data Repository row, camelCase keys |
| 50 | */ |
| 51 | public function __construct(array $data) |
| 52 | { |
| 53 | $this->accountId = Row::int($data, 'accountId'); |
| 54 | $this->investorId = Row::int($data, 'investorId'); |
| 55 | $this->accountNumber = Row::string($data, 'accountNumber'); |
| 56 | $this->balance = Row::string($data, 'balance'); |
| 57 | $this->availableBalance = Row::string($data, 'availableBalance'); |
| 58 | $this->availableForLoan = Row::string($data, 'availableForLoan'); |
| 59 | $this->maxLoanAmount = Row::string($data, 'maxLoanAmount'); |
| 60 | $this->totalOutstandingLoans = Row::string($data, 'totalOutstandingLoans'); |
| 61 | $this->earningsYtd = Row::string($data, 'earningsYtd'); |
| 62 | $this->interestRate = Row::string($data, 'interestRate'); |
| 63 | $this->loanToValueRatio = Row::string($data, 'loanToValueRatio'); |
| 64 | $this->loanInterestRate = Row::string($data, 'loanInterestRate'); |
| 65 | $this->status = Row::string($data, 'status'); |
| 66 | $this->hasAvailableCredit = Row::nullableBool($data, 'hasAvailableCredit') ?? false; |
| 67 | $this->hasActiveLoans = Row::nullableBool($data, 'hasActiveLoans') ?? false; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @return array<mixed> |
| 72 | */ |
| 73 | public function jsonSerialize(): array |
| 74 | { |
| 75 | return get_object_vars($this); |
| 76 | } |
| 77 | } |