Lines 0.00% 0 / 11
Functions and Methods 0.00% 0 / 1
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
AvailabilityCalcSlots 0.00% 0 / 11 0.00% 0 / 1 2 0.00% 0 / 1
 readResponse 0.00% 0 / 11 0.00% 0 / 1 2
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin\Helper;
9
10use BO\Slim\Render;
11use BO\Zmsadmin\BaseController;
12use BO\Zmsentities\Collection\AvailabilityList;
13use Psr\Http\Message\RequestInterface;
14use Psr\Http\Message\ResponseInterface;
15
16class AvailabilityCalcSlots extends BaseController
17{
18    /**
19     * @SuppressWarnings(Param)
20     * @return \Psr\Http\Message\ResponseInterface
21     */
22    #[\Override]
23    public function readResponse(
24        RequestInterface $request,
25        ResponseInterface $response,
26        array $args
27    ) {
28        \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity();
29        $validator = $request->getAttribute('validator');
30        $input = $validator->getInput()->isJson()->assertValid()->getValue();
31        $collection = (new AvailabilityList())->addData($input['availabilityList']);
32
33        $data['maxWorkstationCount'] = $collection->getMaxWorkstationCount();
34        $data['maxSlots'] = $collection->getSummerizedSlotCount();
35        $data['busySlots'] = $input['busySlots'];
36
37        return Render::withJson(
38            $response,
39            $data
40        );
41    }
42}