Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
23 / 23 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| GetAccountByInvestorAction | |
100.00% |
23 / 23 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
22 / 22 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\Account; |
| 6 | |
| 7 | use App\Domain\Account\Service\AccountService; |
| 8 | use App\Renderer\JsonRenderer; |
| 9 | use Psr\Http\Message\ResponseInterface; |
| 10 | use Psr\Http\Message\ServerRequestInterface; |
| 11 | |
| 12 | final readonly class GetAccountByInvestorAction |
| 13 | { |
| 14 | public function __construct( |
| 15 | private AccountService $accountService, |
| 16 | private JsonRenderer $renderer, |
| 17 | ) {} |
| 18 | |
| 19 | /** |
| 20 | * @param ServerRequestInterface $request |
| 21 | * @param ResponseInterface $response |
| 22 | * @param array<string, string> $args |
| 23 | * |
| 24 | * @return ResponseInterface |
| 25 | */ |
| 26 | public function __invoke( |
| 27 | ServerRequestInterface $request, |
| 28 | ResponseInterface $response, |
| 29 | array $args, |
| 30 | ): ResponseInterface { |
| 31 | $investorId = (int)$args['investorId']; |
| 32 | |
| 33 | $account = $this->accountService->getAccountByInvestorId($investorId); |
| 34 | |
| 35 | return $this->renderer->json($response, [ |
| 36 | 'success' => true, |
| 37 | 'data' => [ |
| 38 | 'accountId' => $account->accountId, |
| 39 | 'investorId' => $account->investorId, |
| 40 | 'accountNumber' => $account->accountNumber, |
| 41 | 'balance' => $account->balance, |
| 42 | 'availableBalance' => $account->availableBalance, |
| 43 | 'availableForLoan' => $account->availableForLoan, |
| 44 | 'interestRate' => $account->interestRate, |
| 45 | 'loanToValueRatio' => $account->loanToValueRatio, |
| 46 | 'currency' => $account->currency, |
| 47 | 'status' => $account->status, |
| 48 | 'bankAccountId' => $account->bankAccountId, |
| 49 | 'bankAccountStatus' => $account->bankAccountStatus, |
| 50 | 'openedDate' => $account->openedDate, |
| 51 | 'createdAt' => $account->createdAt, |
| 52 | 'updatedAt' => $account->updatedAt, |
| 53 | ], |
| 54 | ]); |
| 55 | } |
| 56 | } |