Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
ReportsController
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
3
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
 respond
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 complete
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5use Psr\Http\Message\ResponseInterface as Response;
6use Psr\Http\Message\ServerRequestInterface as Request;
7use UppServices\ReportsService;
8
9/**
10 * Slim controller for reports endpoints.
11 * Delegates to ReportsService.
12 */
13class ReportsController
14{
15    private readonly ReportsService $reportsService;
16
17    public function __construct(ReportsService $reportsService)
18    {
19        $this->reportsService = $reportsService;
20    }
21
22    private function respond(Response $response, array $result): Response
23    {
24        $response->getBody()->write($result['output']);
25        return $response->withHeader('Content-Type', $result['contentType']);
26    }
27
28    /** POST /reports/complete - load partial graph by table+objid items */
29    public function complete(Request $request, Response $response): Response
30    {
31        return $this->respond($response, $this->reportsService->complete(
32            (string) $request->getBody(),
33            $request->getQueryParams()
34        ));
35    }
36}