Lines 100.00% 14 / 14
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 readResponse 100.00% 11 / 11 100.00% 1 / 1 3
 [BO\Zmsbackend\Api\BaseController] __invoke 100.00% 3 / 3 100.00% 1 / 1 1
15class ConfigGet extends \BO\Zmsbackend\Api\BaseController
16{
17    /**
18     * @SuppressWarnings(Param)
19     * @return \Psr\Http\Message\ResponseInterface
20     */
21    #[\Override]
22    public function readResponse(
23        \Psr\Http\Message\RequestInterface $request,
24        \Psr\Http\Message\ResponseInterface $response,
25        array $args
26    ) {
27        try {
28            (new \BO\Zmsbackend\Helper\User($request))->checkPermissions();
29        } catch (\Exception $exception) {
30            $token = $request->getHeader('X-Token');
31            if (\App::SECURE_TOKEN != current($token)) {
32                throw new \BO\Zmsbackend\Config\Exception\ConfigAuthentificationFailed();
33            }
34        }
35
36        $config = (new Query())->readEntity();
37
38        $message = \BO\Zmsbackend\Api\Response\Message::create($request);
39        $message->data = $config;
40
41        $response = Render::withLastModified($response, time(), '0');
42        $response = Render::withJson($response, $message, $message->getStatuscode());
43        return $response;
44    }
45}

Inherited from BO\Zmsbackend\Api\BaseController

20    public function __invoke(RequestInterface $request, ResponseInterface $response, array $args)
21    {
22        $request = $this->initRequest($request);
23        $noCacheResponse = \BO\Slim\Render::withLastModified($response, time(), '0');
24        return $this->readResponse($request, $noCacheResponse, $args);
25    }