Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ResendDocumentAction
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
12
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 / 8
0.00% covered (danger)
0.00%
0 / 1
6
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 ResendDocumentAction
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        $body = (array)$request->getParsedBody();
31        $message = isset($body['message']) ? (string)$body['message'] : null;
32
33        $this->pandaDocService->resendDocument($documentId, $message);
34
35        return $this->renderer->json($response, [
36            'success' => true,
37            'message' => 'Document resent',
38        ]);
39    }
40}