Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
41 / 41
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
ScopeAppointmentsByDay
100.00% covered (success)
100.00%
41 / 41
100.00% covered (success)
100.00%
4 / 4
6
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
1 / 1
1
 readSelectedDateTime
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 readSelectedScope
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
2
 readProcessList
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 *
5 * @package Zmsadmin
6 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
7 *
8 */
9
10namespace BO\Zmsadmin;
11
12class ScopeAppointmentsByDay extends BaseController
13{
14    /**
15     * @SuppressWarnings(Param)
16     * @return String
17     */
18    public function readResponse(
19        \Psr\Http\Message\RequestInterface $request,
20        \Psr\Http\Message\ResponseInterface $response,
21        array $args
22    ) {
23        $workstation = \App::$http->readGetResult('/workstation/', [
24            'resolveReferences' => 1,
25            'gql' => Helper\GraphDefaults::getWorkstation()
26        ])->getEntity();
27        $workstationRequest = new \BO\Zmsclient\WorkstationRequests(\App::$http, $workstation);
28        $selectedDateTime = static::readSelectedDateTime($args['date']);
29        $scope = static::readSelectedScope($workstation, $workstationRequest, $args['id']);
30        $processList = static::readProcessList($workstationRequest, $selectedDateTime);
31
32        // rendering
33        return \BO\Slim\Render::withHtml(
34            $response,
35            'page/scopeAppointmentsByDay.twig',
36            array(
37                'title' =>
38                    'Termine für '
39                    . $scope->contact['name']
40                    . ' am '
41                    . $selectedDateTime->format('d.m.Y'),
42                'menuActive' => 'counter',
43                'workstation' => $workstation,
44                'date' => $selectedDateTime->format('Y-m-d'),
45                'scope' => $scope,
46                'clusterEnabled' => $workstation->isClusterEnabled(),
47                'processList' => $processList,
48            )
49        );
50    }
51
52    public static function readSelectedDateTime($selectedDate)
53    {
54         return $selectedDate ? new \DateTimeImmutable($selectedDate) : \App::$now;
55    }
56
57    public static function readSelectedScope($workstation, $workstationRequest, $scopeId)
58    {
59        if ($workstation->getScope()->id != $scopeId) {
60            $scope = \App::$http->readGetResult('/scope/' . $scopeId . '/', [
61                'gql' => Helper\GraphDefaults::getScope()
62            ])->getEntity();
63            $workstationRequest->setDifferentScope($scope);
64        }
65        return $workstationRequest->getScope();
66    }
67
68    public static function readProcessList($workstationRequest, $selectedDateTime)
69    {
70        $processList = $workstationRequest->readProcessListByDate(
71            $selectedDateTime,
72            Helper\GraphDefaults::getProcess()
73        );
74        // data refinement
75        return $processList
76            ->toQueueList(\App::$now)
77            ->withStatus(['confirmed', 'queued'])
78            ->withSortedArrival()
79            ->toProcessList();
80    }
81}