Lines
100.00%
11 / 11
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| WorkstationStatus | 100.00% | 11 / 11 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| readResponse | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 1 | |||||
| withFixedLastLogin | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * @package Zmsadmin | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | **/ | |
| 7 | ||
| 8 | namespace BO\Zmsadmin; | |
| 9 | ||
| 10 | use BO\Slim\Render; | |
| 11 | ||
| 12 | /** | |
| 13 | * Handle requests concerning services | |
| 14 | * | |
| 15 | */ | |
| 16 | class 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 | } |