Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
88.89% covered (warning)
88.89%
16 / 18
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Status
88.89% covered (warning)
88.89%
16 / 18
0.00% covered (danger)
0.00%
0 / 1
4.02
0.00% covered (danger)
0.00%
0 / 1
 readResponse
88.89% covered (warning)
88.89%
16 / 18
0.00% covered (danger)
0.00%
0 / 1
4.02
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        return Render::withHtml(
54            $response,
55            'page/status.twig',
56            array(
57                'title' => 'Status der Terminvereinbarung',
58                'workstation' => $workstation,
59                'status' => $result->getEntity(),
60                'isSuperuser' => $workstation->getUseraccount()->isSuperUser(),
61            )
62        );
63    }
64}