Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| GetAdminFundCashflowRequestsAction | |
0.00% |
0 / 22 |
|
0.00% |
0 / 2 |
156 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
132 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\Admin; |
| 6 | |
| 7 | use App\Domain\Funds\Service\FundCashflowRequestAdminService; |
| 8 | use App\Renderer\JsonRenderer; |
| 9 | use Psr\Http\Message\ResponseInterface; |
| 10 | use Psr\Http\Message\ServerRequestInterface; |
| 11 | |
| 12 | final readonly class GetAdminFundCashflowRequestsAction |
| 13 | { |
| 14 | public function __construct( |
| 15 | private FundCashflowRequestAdminService $service, |
| 16 | private JsonRenderer $renderer, |
| 17 | ) {} |
| 18 | |
| 19 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface |
| 20 | { |
| 21 | $params = $request->getQueryParams(); |
| 22 | |
| 23 | $page = max(1, (int)($params['page'] ?? 1)); |
| 24 | $limit = min(100, max(1, (int)($params['limit'] ?? 25))); |
| 25 | $status = isset($params['status']) && $params['status'] !== '' ? (string)$params['status'] : null; |
| 26 | $requestType = isset($params['requestType']) && $params['requestType'] !== '' ? (string)$params['requestType'] : null; |
| 27 | $search = isset($params['search']) && $params['search'] !== '' ? (string)$params['search'] : null; |
| 28 | $startDate = isset($params['startDate']) && $params['startDate'] !== '' ? (string)$params['startDate'] : null; |
| 29 | $endDate = isset($params['endDate']) && $params['endDate'] !== '' ? (string)$params['endDate'] : null; |
| 30 | |
| 31 | $result = $this->service->listRequests($page, $limit, $status, $requestType, $search, $startDate, $endDate); |
| 32 | |
| 33 | return $this->renderer->json($response, [ |
| 34 | 'success' => true, |
| 35 | 'data' => [ |
| 36 | 'requests' => $result['data'], |
| 37 | 'pagination' => [ |
| 38 | 'total' => $result['total'], |
| 39 | 'page' => $page, |
| 40 | 'limit' => $limit, |
| 41 | 'totalPages' => (int)ceil($result['total'] / $limit), |
| 42 | ], |
| 43 | ], |
| 44 | ]); |
| 45 | } |
| 46 | } |