Lines 100.00% 24 / 24
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 readResponse 100.00% 21 / 21 100.00% 1 / 1 4
 [BO\Zmsbackend\Api\BaseController] __invoke 100.00% 3 / 3 100.00% 1 / 1 1
15class ConflictListByScope 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        (new \BO\Zmsbackend\Helper\User($request))->checkPermissions('appointment');
28        $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(1)->getValue();
29
30        $startDateFormatted = Validator::param('startDate')->isString()->getValue();
31        $endDateFormatted = Validator::param('endDate')->isString()->getValue();
32        $startDate = ($startDateFormatted) ? new \BO\Zmsentities\Helper\DateTime($startDateFormatted) : \App::$now;
33        $endDate = ($endDateFormatted) ? new \BO\Zmsentities\Helper\DateTime($endDateFormatted) : \App::$now;
34
35        $scope = (new \BO\Zmsbackend\Scope\Service\Scope())->readEntity($args['id'], 1);
36        if (!$scope) {
37            throw new \BO\Zmsbackend\Scope\Exception\ScopeNotFound();
38        }
39
40        $conflictList = (new \BO\Zmsbackend\Process\Service\Process())->readConflictListByScopeAndTime(
41            $scope,
42            $startDate,
43            $endDate,
44            \App::$now,
45            $resolveReferences
46        );
47
48        $message = \BO\Zmsbackend\Api\Response\Message::create($request);
49        $message->data = $conflictList;
50
51        $response = Render::withLastModified($response, time(), '0');
52        $response = Render::withJson($response, $message, 200);
53        return $response;
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    }