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 \Psr\Http\Message\ResponseInterface
17     */
18    #[\Override]
19    public function readResponse(
20        \Psr\Http\Message\RequestInterface $request,
21        \Psr\Http\Message\ResponseInterface $response,
22        array $args
23    ): \Psr\Http\Message\ResponseInterface {
24        $workstation = \App::$http->readGetResult('/workstation/', [
25            'resolveReferences' => 1,
26            'gql' => Helper\GraphDefaults::getWorkstation()
27        ])->getEntity();
28        $workstationRequest = new \BO\Zmsclient\WorkstationRequests(\App::$http, $workstation);
29        $selectedDateTime = static::readSelectedDateTime($args['date']);
30        $scope = static::readSelectedScope($workstation, $workstationRequest, $args['id']);
31        $processList = static::readProcessList($workstationRequest, $selectedDateTime);
32
33        // rendering
34        return \BO\Slim\Render::withHtml(
35            $response,
36            'page/scopeAppointmentsByDay.twig',
37            array(
38                'title' =>
39                    'Termine für '
40                    . $scope->contact['name']
41                    . ' am '
42                    . $selectedDateTime->format('d.m.Y'),
43                'menuActive' => 'counter',
44                'workstation' => $workstation,
45                'date' => $selectedDateTime->format('Y-m-d'),
46                'scope' => $scope,
47                'clusterEnabled' => $workstation->isClusterEnabled(),
48                'processList' => $processList,
49            )
50        );
51    }
52
53    public static function readSelectedDateTime($selectedDate)
54    {
55         return $selectedDate ? new \DateTimeImmutable($selectedDate) : \App::$now;
56    }
57
58    public static function readSelectedScope($workstation, $workstationRequest, $scopeId)
59    {
60        if ($workstation->getScope()->id != $scopeId) {
61            $scope = \App::$http->readGetResult('/scope/' . $scopeId . '/', [
62                'gql' => Helper\GraphDefaults::getScope()
63            ])->getEntity();
64            $workstationRequest->setDifferentScope($scope);
65        }
66        return $workstationRequest->getScope();
67    }
68
69    public static function readProcessList($workstationRequest, $selectedDateTime)
70    {
71        $processList = $workstationRequest->readProcessListByDate(
72            $selectedDateTime,
73            Helper\GraphDefaults::getProcess()
74        );
75        // data refinement
76        return $processList
77            ->toQueueList(\App::$now)
78            ->withStatus(['confirmed', 'queued'])
79            ->withSortedArrival()
80            ->toProcessList();
81    }
82}