Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| LoanEligibilityData | |
0.00% |
0 / 19 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| fromRow | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Domain\Loan\Data; |
| 6 | |
| 7 | /** |
| 8 | * |
| 9 | */ |
| 10 | final readonly class LoanEligibilityData |
| 11 | { |
| 12 | public function __construct( |
| 13 | public bool $eligible, |
| 14 | public bool $allowMultipleLoans, |
| 15 | public string $reason, |
| 16 | public string $maxLoanAmount, |
| 17 | public string $currentBalance, |
| 18 | public string $ltvPercentage, |
| 19 | public string $minRequiredBalance |
| 20 | ) {} |
| 21 | |
| 22 | /** |
| 23 | * @param array<string, mixed> $row |
| 24 | */ |
| 25 | public static function fromRow(array $row): self |
| 26 | { |
| 27 | return new self( |
| 28 | eligible: (bool)$row['eligible'], |
| 29 | allowMultipleLoans: (bool)$row['allowMultipleLoans'], |
| 30 | reason: (string)$row['reason'], |
| 31 | maxLoanAmount: (string)($row['maxLoanAmount'] ?? $row['max_loan_amount'] ?? '0'), |
| 32 | currentBalance: (string)($row['currentBalance'] ?? $row['current_balance'] ?? '0'), |
| 33 | ltvPercentage: (string)($row['ltvPercentage'] ?? $row['ltv_percentage'] ?? '0'), |
| 34 | minRequiredBalance: (string)($row['minRequiredBalance'] ?? $row['min_required_balance'] ?? '0'), |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * @return array<string, mixed> |
| 40 | */ |
| 41 | public function toArray(): array |
| 42 | { |
| 43 | return [ |
| 44 | 'eligible' => $this->eligible, |
| 45 | 'allowMultipleLoans' => $this->allowMultipleLoans, |
| 46 | 'reason' => $this->reason, |
| 47 | 'maxLoanAmount' => $this->maxLoanAmount, |
| 48 | 'currentBalance' => $this->currentBalance, |
| 49 | 'ltvPercentage' => $this->ltvPercentage, |
| 50 | 'minRequiredBalance' => $this->minRequiredBalance, |
| 51 | ]; |
| 52 | } |
| 53 | } |