Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ScopeQueue | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
4 |
1 | <?php |
2 | |
3 | /** |
4 | * @package ZMS API |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsapi; |
9 | |
10 | use BO\Slim\Render; |
11 | use BO\Mellon\Validator; |
12 | use BO\Zmsdb\Scope as Query; |
13 | use BO\Zmsentities\Helper\DateTime; |
14 | |
15 | class ScopeQueue extends BaseController |
16 | { |
17 | /** |
18 | * @SuppressWarnings(Param) |
19 | * @return String |
20 | */ |
21 | public function readResponse( |
22 | \Psr\Http\Message\RequestInterface $request, |
23 | \Psr\Http\Message\ResponseInterface $response, |
24 | array $args |
25 | ) { |
26 | $query = new Query(); |
27 | $selectedDate = Validator::param('date')->isString()->getValue(); |
28 | $dateTime = ($selectedDate) ? (new DateTime($selectedDate))->modify(\App::$now->format('H:i')) : \App::$now; |
29 | |
30 | $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(0)->getValue(); |
31 | $scope = (new \BO\Zmsdb\Scope())->readWithWorkstationCount($args['id'], \App::$now, $resolveReferences); |
32 | if (! $scope) { |
33 | throw new Exception\Scope\ScopeNotFound(); |
34 | } |
35 | $queueList = $query->readQueueListWithWaitingTime($scope, $dateTime, $resolveReferences); |
36 | |
37 | $message = Response\Message::create($request); |
38 | if ((new Helper\User($request))->hasRights()) { |
39 | (new Helper\User($request))->checkRights('basic'); |
40 | } else { |
41 | $queueList = $queueList->withLessData(); |
42 | $message->meta->reducedData = true; |
43 | } |
44 | $message->data = $queueList; |
45 | |
46 | $response = Render::withLastModified($response, time(), '0'); |
47 | $response = Render::withJson($response, $message, 200); |
48 | return $response; |
49 | } |
50 | } |