Lines 90.00% 18 / 20
Functions and Methods 0.00% 0 / 1
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
Status 90.00% 18 / 20 0.00% 0 / 1 5.03 0.00% 0 / 1
 readResponse 90.00% 18 / 20 0.00% 0 / 1 5.03
1<?php
2
3/**
4 *
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 *
7 */
8
9namespace BO\Zmsstatistic;
10
11use BO\Slim\Render;
12use BO\Zmsentities\Exception\UserAccountMissingLogin;
13use BO\Zmsentities\Workstation;
14use Psr\Http\Message\RequestInterface;
15use Psr\Http\Message\ResponseInterface;
16
17/**
18 * Handle requests concerning services
19 */
20class Status extends BaseController
21{
22    protected bool $withAccess = false;
23
24    private const array MISSING_LOGIN_TEMPLATES = [
25        'BO\\Zmsentities\\Exception\\UserAccountMissingLogin',
26        'BO\\Zmsbackend\\Workstation\\Exception\\WorkstationNotFound',
27    ];
28
29    /**
30     * @SuppressWarnings(UnusedFormalParameter)
31     * @return ResponseInterface
32     */
33    #[\Override]
34    public function readResponse(
35        RequestInterface $request,
36        ResponseInterface $response,
37        array $args
38    ): mixed {
39        try {
40            $workstation = \App::http()->readGetResult('/workstation/')->getEntity();
41        } catch (\BO\Zmsclient\Exception $exception) {
42            if (in_array($exception->template, self::MISSING_LOGIN_TEMPLATES, true)) {
43                throw new UserAccountMissingLogin();
44            }
45            throw $exception;
46        }
47
48        if (!$workstation instanceof Workstation) {
49            throw new UserAccountMissingLogin();
50        }
51
52        $result = \App::http()->readGetResult('/status/');
53        $isSuperuser = $workstation->getUseraccount()->isSuperUser();
54        return Render::withHtml(
55            $response,
56            'page/status.twig',
57            array(
58                'title' => 'Status der Terminvereinbarung',
59                'workstation' => $workstation,
60                'status' => $result->getEntity(),
61                'isSuperuser' => $isSuperuser,
62                'phpVersion' => $isSuperuser ? PHP_VERSION : null,
63            )
64        );
65    }
66}