Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| GetAdminInvestorsAction | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\Admin; |
| 6 | |
| 7 | use App\Domain\Admin\Service\AdminService; |
| 8 | use App\Renderer\JsonRenderer; |
| 9 | use Psr\Http\Message\ResponseInterface; |
| 10 | use Psr\Http\Message\ServerRequestInterface; |
| 11 | |
| 12 | /** |
| 13 | * Get paginated list of investors for admin. |
| 14 | * |
| 15 | * GET /api/admin/investors |
| 16 | */ |
| 17 | final class GetAdminInvestorsAction |
| 18 | { |
| 19 | private AdminService $service; |
| 20 | |
| 21 | private JsonRenderer $renderer; |
| 22 | |
| 23 | public function __construct( |
| 24 | AdminService $service, |
| 25 | JsonRenderer $renderer, |
| 26 | ) { |
| 27 | $this->service = $service; |
| 28 | $this->renderer = $renderer; |
| 29 | } |
| 30 | |
| 31 | public function __invoke( |
| 32 | ServerRequestInterface $request, |
| 33 | ResponseInterface $response, |
| 34 | ): ResponseInterface { |
| 35 | $params = $request->getQueryParams(); |
| 36 | |
| 37 | $page = isset($params['page']) ? (int)$params['page'] : 1; |
| 38 | $limit = isset($params['limit']) ? (int)$params['limit'] : 20; |
| 39 | $search = $params['search'] ?? null; |
| 40 | $kycStatus = $params['kycStatus'] ?? null; |
| 41 | $status = $params['status'] ?? null; |
| 42 | |
| 43 | $result = $this->service->getInvestorsList($page, $limit, $search, $kycStatus, $status); |
| 44 | |
| 45 | return $this->renderer->json($response, [ |
| 46 | 'success' => true, |
| 47 | 'data' => $result, |
| 48 | ]); |
| 49 | } |
| 50 | } |