Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
WorkstationStatus
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 withFixedLastLogin
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin;
9
10use BO\Slim\Render;
11
12/**
13 * Handle requests concerning services
14 *
15 */
16class WorkstationStatus extends BaseController
17{
18    /**
19     * @SuppressWarnings(Param)
20     * @return \Psr\Http\Message\ResponseInterface
21     */
22    #[\Override]
23    public function readResponse(
24        \Psr\Http\Message\RequestInterface $request,
25        \Psr\Http\Message\ResponseInterface $response,
26        array $args
27    ): \Psr\Http\Message\ResponseInterface {
28        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity();
29        $workstation = $this->withFixedLastLogin($workstation);
30        $response = Render::withLastModified($response, time(), '0');
31
32        return Render::withJson($response, ['workstation' => $workstation]);
33    }
34
35    protected function withFixedLastLogin($workstation)
36    {
37        $dateTime = (new \DateTime())->setTimestamp($workstation->getUseraccount()->lastLogin);
38        $hour = \App::$now->format('H');
39        $minute = $dateTime->format('i');
40        $second = $dateTime->format('s');
41        $dateTime->setTime($hour, $minute, $second);
42        $workstation->getUseraccount()->lastLogin = $dateTime->getTimestamp();
43        return $workstation;
44    }
45}