Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| GetUploadAction | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
9 / 9 |
|
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 | * Single document plus full event history. Powers the admin review |
| 14 | * detail surface. |
| 15 | */ |
| 16 | final readonly class GetUploadAction |
| 17 | { |
| 18 | public function __construct( |
| 19 | private InvestorDocumentService $service, |
| 20 | private JsonRenderer $renderer, |
| 21 | ) {} |
| 22 | |
| 23 | /** |
| 24 | * @param array<string, string> $args |
| 25 | * @param ServerRequestInterface $request |
| 26 | * @param ResponseInterface $response |
| 27 | */ |
| 28 | public function __invoke( |
| 29 | ServerRequestInterface $request, |
| 30 | ResponseInterface $response, |
| 31 | array $args, |
| 32 | ): ResponseInterface { |
| 33 | $documentId = (int)$args['id']; |
| 34 | |
| 35 | $payload = $this->service->getForAdmin($documentId); |
| 36 | |
| 37 | return $this->renderer->json($response, [ |
| 38 | 'success' => true, |
| 39 | 'data' => [ |
| 40 | 'document' => $payload['document']->toArray(), |
| 41 | 'events' => array_map(static fn($e) => $e->toArray(), $payload['events']), |
| 42 | ], |
| 43 | ]); |
| 44 | } |
| 45 | } |