Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
GetInvestorAgreementsAction
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __invoke
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Action\Document\Admin;
6
7use App\Domain\Document\Service\InvestorAgreementService;
8use App\Renderer\JsonRenderer;
9use Psr\Http\Message\ResponseInterface;
10use Psr\Http\Message\ServerRequestInterface;
11
12/**
13 * Admin progress view: a specific investor's outbound PandaDoc agreements
14 * (investment + loan documents). Same refresh-on-read behaviour as the
15 * investor-facing list, scoped to the {investorId} route arg.
16 */
17final readonly class GetInvestorAgreementsAction
18{
19    public function __construct(
20        private InvestorAgreementService $agreements,
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->agreements->listForInvestor($investorId);
37
38        return $this->renderer->json($response, [
39            'success' => true,
40            'data' => ['documents' => $documents],
41        ]);
42    }
43}