Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
WorkstationGet
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3/**
4 * @package ZMS API
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8 namespace BO\Zmsapi;
9
10 use BO\Slim\Render;
11 use BO\Mellon\Validator;
12
13class WorkstationGet extends BaseController
14{
15    /**
16     * @SuppressWarnings(Param)
17     * @return \Psr\Http\Message\ResponseInterface
18     */
19    #[\Override]
20    public function readResponse(
21        \Psr\Http\Message\RequestInterface $request,
22        \Psr\Http\Message\ResponseInterface $response,
23        array $args
24    ) {
25        $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(1)->getValue();
26        $workstation = (new Helper\User($request, $resolveReferences))->checkPermissions();
27
28        // Check if the password field exists and remove it from the response
29        if (isset($workstation['useraccount']['password'])) {
30            unset($workstation['useraccount']['password']);
31        }
32
33        $message = Response\Message::create($request);
34        $message->data = $workstation;
35
36        $response = Render::withLastModified($response, time(), '0');
37        $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode());
38        return $response;
39    }
40}