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