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 String
21     */
22    public function readResponse(
23        \Psr\Http\Message\RequestInterface $request,
24        \Psr\Http\Message\ResponseInterface $response,
25        array $args
26    ) {
27        $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity();
28        $workstation = $this->withFixedLastLogin($workstation);
29        $response = Render::withLastModified($response, time(), '0');
30
31        return Render::withJson($response, ['workstation' => $workstation]);
32    }
33
34    protected function withFixedLastLogin($workstation)
35    {
36        $dateTime = (new \DateTime())->setTimestamp($workstation->getUseraccount()->lastLogin);
37        $hour = \App::$now->format('H');
38        $minute = $dateTime->format('i');
39        $second = $dateTime->format('s');
40        $dateTime->setTime($hour, $minute, $second);
41        $workstation->getUseraccount()->lastLogin = $dateTime->getTimestamp();
42        return $workstation;
43    }
44}