Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CheckEligibilityAction | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\Loan; |
| 6 | |
| 7 | use App\Domain\Loan\Service\LoanService; |
| 8 | use App\Renderer\JsonRenderer; |
| 9 | use Psr\Http\Message\ResponseInterface; |
| 10 | use Psr\Http\Message\ServerRequestInterface; |
| 11 | |
| 12 | final readonly class CheckEligibilityAction |
| 13 | { |
| 14 | public function __construct( |
| 15 | private LoanService $loanService, |
| 16 | private JsonRenderer $renderer |
| 17 | ) {} |
| 18 | |
| 19 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface |
| 20 | { |
| 21 | $investorId = (int)$request->getAttribute('investorId'); |
| 22 | $eligibility = $this->loanService->checkEligibility($investorId); |
| 23 | $config = $this->loanService->getConfig(); |
| 24 | |
| 25 | return $this->renderer->json($response, [ |
| 26 | 'success' => true, |
| 27 | 'data' => [ |
| 28 | 'eligibility' => $eligibility->toArray(), |
| 29 | 'availableTerms' => LoanService::getValidTerms(), |
| 30 | 'interestRate' => $config['default_interest_rate'] ?? '8.00', |
| 31 | ], |
| 32 | ]); |
| 33 | } |
| 34 | } |