Lines 100.00% 19 / 19
Methods 100.00% 3 / 3
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 readResponse 100.00% 11 / 11 100.00% 1 / 1 1
 testProcessData 100.00% 5 / 5 100.00% 1 / 1 3
 [BO\Zmsbackend\Api\BaseController] __invoke 100.00% 3 / 3 100.00% 1 / 1 1
15class ProcessIcs 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        $status = Validator::param('status')->isNumber()->setDefault('appointment')->getValue();
28        $this->testProcessData($args['id'], $args['authKey']);
29        $process = (new \BO\Zmsbackend\Process\Service\Process())->readEntity($args['id'], $args['authKey'], 2);
30
31        $config = (new \BO\Zmsbackend\Config\Service\Config())->readEntity();
32        $templateProvider = new \BO\Zmsbackend\Helper\MailTemplateProvider($process);
33        $ics = \BO\Zmsentities\Helper\Messaging::getMailIcs($process, $config, $status, null, null, $templateProvider);
34
35        $message = \BO\Zmsbackend\Api\Response\Message::create($request);
36        $message->data = $ics;
37
38        $response = Render::withLastModified($response, time(), '0');
39        $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode());
40        return $response;
41    }
42
43    /**
44     * @return void
45     */
46    protected function testProcessData($processId, $authKey)
47    {
48        $authCheck = (new \BO\Zmsbackend\Process\Service\Process())->readAuthKeyByProcessId($processId);
49        if (! $authCheck) {
50            throw new \BO\Zmsbackend\Process\Exception\ProcessNotFound();
51        } elseif ($authCheck['authKey'] !== $authKey) {
52            throw new \BO\Zmsbackend\Process\Exception\AuthKeyMatchFailed();
53        }
54    }
55}

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    }