Lines 0.00% 0 / 14
Functions and Methods 0.00% 0 / 1
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ScopeAvailabilityDayClosure 0.00% 0 / 14 0.00% 0 / 1 2 0.00% 0 / 1
 readResponse 0.00% 0 / 14 0.00% 0 / 1 2
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin;
9
10use BO\Slim\Render;
11use Psr\Http\Message\ResponseInterface;
12
13class ScopeAvailabilityDayClosure extends BaseController
14{
15    /**
16     * @SuppressWarnings(Param)
17     * @return ResponseInterface
18     */
19    #[\Override]
20    public function readResponse(
21        \Psr\Http\Message\RequestInterface $request,
22        \Psr\Http\Message\ResponseInterface $response,
23        array $args
24    ): ResponseInterface {
25        $scopeId = $args['id'];
26        $date = $args['date'];
27
28        $closureToggled = \App::$http->readPostResult(
29            '/scope/' . $scopeId . '/availability/' . $date . '/closure/toggle/',
30            new \BO\Zmsentities\Closure()
31        )->getEntity();
32
33        // Plain boolean so the day-view banner can update without relying on
34        // schema serialization of the dynamic `existing` property.
35        return \BO\Slim\Render::withJson(
36            $response,
37            [
38                'closure' => [
39                    'existing' => (bool) ($closureToggled['existing'] ?? false),
40                ],
41            ]
42        );
43    }
44}