Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
CreateSigningSessionAction
0.00% covered (danger)
0.00%
0 / 8
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 / 7
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\Auth\Data\UserAuthData;
8use App\Domain\Document\Service\PandaDocService;
9use App\Renderer\JsonRenderer;
10use Psr\Http\Message\ResponseInterface;
11use Psr\Http\Message\ServerRequestInterface;
12
13final readonly class CreateSigningSessionAction
14{
15    public function __construct(
16        private PandaDocService $pandaDocService,
17        private JsonRenderer $renderer,
18    ) {}
19
20    /**
21     * @param array<string, string> $args
22     * @param ServerRequestInterface $request
23     * @param ResponseInterface $response
24     */
25    public function __invoke(
26        ServerRequestInterface $request,
27        ResponseInterface $response,
28        array $args,
29    ): ResponseInterface {
30        $documentId = $args['id'];
31
32        /** @var UserAuthData $user */
33        $user = $request->getAttribute('user');
34        $session = $this->pandaDocService->createSigningSession($documentId, $user->email);
35
36        return $this->renderer->json($response, [
37            'success' => true,
38            'data' => $session,
39        ]);
40    }
41}