Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ListInvestorUploadsAction | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\Document\Submission\Admin; |
| 6 | |
| 7 | use App\Domain\Document\Submission\Service\InvestorDocumentService; |
| 8 | use App\Renderer\JsonRenderer; |
| 9 | use Psr\Http\Message\ResponseInterface; |
| 10 | use Psr\Http\Message\ServerRequestInterface; |
| 11 | |
| 12 | /** |
| 13 | * All submissions for a single investor. Used by the investor detail |
| 14 | * page so admins can see the full audit trail (pending, accepted, |
| 15 | * rejected, and discarded) for a given investor. |
| 16 | */ |
| 17 | final readonly class ListInvestorUploadsAction |
| 18 | { |
| 19 | public function __construct( |
| 20 | private InvestorDocumentService $service, |
| 21 | private JsonRenderer $renderer, |
| 22 | ) {} |
| 23 | |
| 24 | /** |
| 25 | * @param array<string, string> $args |
| 26 | * @param ServerRequestInterface $request |
| 27 | * @param ResponseInterface $response |
| 28 | */ |
| 29 | public function __invoke( |
| 30 | ServerRequestInterface $request, |
| 31 | ResponseInterface $response, |
| 32 | array $args, |
| 33 | ): ResponseInterface { |
| 34 | $investorId = (int)$args['investorId']; |
| 35 | |
| 36 | $documents = $this->service->listForInvestorAsAdmin($investorId); |
| 37 | |
| 38 | return $this->renderer->json($response, [ |
| 39 | 'success' => true, |
| 40 | 'data' => [ |
| 41 | 'documents' => array_map(static fn($d) => $d->toArray(), $documents), |
| 42 | ], |
| 43 | ]); |
| 44 | } |
| 45 | } |