Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
21 / 21
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ConflictListByScope
100.00% covered (success)
100.00%
21 / 21
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
21 / 21
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3/**
4 * @package ZMS API
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsapi;
9
10use BO\Slim\Render;
11use BO\Mellon\Validator;
12use BO\Zmsdb\Process;
13use BO\Zmsdb\Scope;
14
15class ConflictListByScope extends 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 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 Scope())->readEntity($args['id'], 1);
36        if (!$scope) {
37            throw new Exception\Scope\ScopeNotFound();
38        }
39
40        $conflictList = (new Process())->readConflictListByScopeAndTime(
41            $scope,
42            $startDate,
43            $endDate,
44            \App::$now,
45            $resolveReferences
46        );
47
48        $message = 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}