Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
GetDocumentAction
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 __invoke
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace App\Action\Document;
6
7use App\Domain\Document\Service\PandaDocService;
8use App\Renderer\JsonRenderer;
9use Psr\Http\Message\ResponseInterface;
10use Psr\Http\Message\ServerRequestInterface;
11
12final readonly class GetDocumentAction
13{
14    public function __construct(
15        private PandaDocService $pandaDocService,
16        private JsonRenderer $renderer,
17    ) {}
18
19    /**
20     * @param array<string, string> $args
21     * @param ServerRequestInterface $request
22     * @param ResponseInterface $response
23     */
24    public function __invoke(
25        ServerRequestInterface $request,
26        ResponseInterface $response,
27        array $args,
28    ): ResponseInterface {
29        $documentId = $args['id'];
30        $document = $this->pandaDocService->getDocumentDetails($documentId);
31
32        return $this->renderer->json($response, [
33            'success' => true,
34            'data' => $document,
35        ]);
36    }
37}