Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.91% covered (success)
90.91%
20 / 22
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
CounterAppointmentTimes
90.91% covered (success)
90.91%
20 / 22
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 1
 readResponse
90.91% covered (success)
90.91%
20 / 22
0.00% covered (danger)
0.00%
0 / 1
2.00
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin;
9
10use BO\Zmsentities\Helper\DateTime;
11
12class CounterAppointmentTimes 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        $validator = $request->getAttribute('validator');
25        $selectedDate = $validator->getParameter('selecteddate')->isString()->getValue();
26        $dateTime = new DateTime($selectedDate);
27        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 0])->getEntity();
28
29        try {
30            $availabilityList = \App::$http
31            ->readGetResult('/scope/' . $workstation->scope['id'] . '/availability/', [
32                'startDate' => $selectedDate,
33                'endDate' => $selectedDate
34            ], \App::CONFIG_SECURE_TOKEN)
35            ->getCollection()
36            ->withDateTime($dateTime);
37        } catch (\Exception $e) {
38            $availabilityList = [];
39        }
40
41        return \BO\Slim\Render::withHtml(
42            $response,
43            'block/appointment/times.twig',
44            array(
45                'workstation' => $workstation,
46                'availabilityList' => $availabilityList,
47                'selectedDate' => $selectedDate
48            )
49        );
50    }
51}