Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| GetAdminInvestorAllocationsAction | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |||
| 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 InvalidArgumentException; |
| 10 | use Psr\Http\Message\ResponseInterface; |
| 11 | use Psr\Http\Message\ServerRequestInterface; |
| 12 | |
| 13 | /** |
| 14 | * Get investor allocations for admin. |
| 15 | * |
| 16 | * GET /api/admin/investors/{id}/allocations |
| 17 | */ |
| 18 | final class GetAdminInvestorAllocationsAction |
| 19 | { |
| 20 | public function __construct( |
| 21 | private AdminService $service, |
| 22 | private JsonRenderer $renderer, |
| 23 | ) {} |
| 24 | |
| 25 | public function __invoke( |
| 26 | ServerRequestInterface $request, |
| 27 | ResponseInterface $response, |
| 28 | array $args, |
| 29 | ): ResponseInterface { |
| 30 | $investorId = (int)($args['id'] ?? 0); |
| 31 | |
| 32 | if ($investorId <= 0) { |
| 33 | throw new InvalidArgumentException('Invalid investor ID'); |
| 34 | } |
| 35 | |
| 36 | $allocations = $this->service->getInvestorAllocations($investorId); |
| 37 | |
| 38 | return $this->renderer->json($response, [ |
| 39 | 'success' => true, |
| 40 | 'data' => [ |
| 41 | 'allocations' => $allocations, |
| 42 | ], |
| 43 | ]); |
| 44 | } |
| 45 | } |