Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
AccountData
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\Account\Data;
6
7use App\Support\Row;
8use JsonSerializable;
9
10/**
11 * Data transfer object for account information.
12 *
13 * All properties use camelCase. Repository handles snake_case conversion.
14 *
15 * Monetary values are stored as strings to preserve exact decimal
16 * precision from PostgreSQL NUMERIC types.
17 */
18final class AccountData 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 $interestRate;
33
34    public string $loanToValueRatio;
35
36    public string $currency;
37
38    public string $openedDate;
39
40    public string $status;
41
42    public ?string $bankAccountId;
43
44    public string $bankAccountStatus;
45
46    public string $createdAt;
47
48    public string $updatedAt;
49
50    /**
51     * @param array<mixed> $data Repository row, camelCase keys
52     */
53    public function __construct(array $data)
54    {
55        $this->accountId = Row::int($data, 'accountId');
56        $this->investorId = Row::int($data, 'investorId');
57        $this->accountNumber = Row::string($data, 'accountNumber');
58        $this->balance = Row::string($data, 'balance');
59        $this->availableBalance = Row::string($data, 'availableBalance');
60        $this->availableForLoan = Row::string($data, 'availableForLoan');
61        $this->interestRate = Row::string($data, 'interestRate');
62        $this->loanToValueRatio = Row::string($data, 'loanToValueRatio');
63        $this->currency = Row::string($data, 'currency');
64        $this->openedDate = Row::string($data, 'openedDate');
65        $this->status = Row::string($data, 'status');
66        $this->bankAccountId = Row::nullableString($data, 'bankAccountId');
67        $this->bankAccountStatus = Row::string($data, 'bankAccountStatus');
68        $this->createdAt = Row::string($data, 'createdAt');
69        $this->updatedAt = Row::string($data, 'updatedAt');
70    }
71
72    /**
73     * @return array<mixed>
74     */
75    public function jsonSerialize(): array
76    {
77        return get_object_vars($this);
78    }
79}