Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ListPendingFundingRequestsAction | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\Funding; |
| 6 | |
| 7 | use App\Domain\Exception\ForbiddenException; |
| 8 | use App\Domain\Funding\Service\FundingRequestService; |
| 9 | use App\Renderer\JsonRenderer; |
| 10 | use App\Support\Row; |
| 11 | use Psr\Http\Message\ResponseInterface; |
| 12 | use Psr\Http\Message\ServerRequestInterface; |
| 13 | |
| 14 | /** |
| 15 | * Admin queue of investor-initiated funding requests awaiting action (FSC-21). |
| 16 | * |
| 17 | * GET /api/admin/funding-requests/pending |
| 18 | */ |
| 19 | final readonly class ListPendingFundingRequestsAction |
| 20 | { |
| 21 | public function __construct( |
| 22 | private FundingRequestService $service, |
| 23 | private JsonRenderer $renderer, |
| 24 | ) {} |
| 25 | |
| 26 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface |
| 27 | { |
| 28 | $attributes = $request->getAttributes(); |
| 29 | $role = Row::nullableString($attributes, 'userRole') ?? ''; |
| 30 | if ($role !== 'admin' && $role !== 'super_admin') { |
| 31 | throw new ForbiddenException('Admin access required'); |
| 32 | } |
| 33 | |
| 34 | $pending = $this->service->listPending(); |
| 35 | |
| 36 | return $this->renderer->json($response, [ |
| 37 | 'success' => true, |
| 38 | 'data' => [ |
| 39 | 'fundingRequests' => array_map(static fn($r): array => $r->toAdminArray(), $pending), |
| 40 | ], |
| 41 | ]); |
| 42 | } |
| 43 | } |