Lines 100.00% 12 / 12
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 readResponse 100.00% 9 / 9 100.00% 1 / 1 2
 [BO\Zmsbackend\Api\BaseController] __invoke 100.00% 3 / 3 100.00% 1 / 1 1
13class WorkstationGet extends \BO\Zmsbackend\Api\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 \BO\Zmsbackend\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 = \BO\Zmsbackend\Api\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}

Inherited from BO\Zmsbackend\Api\BaseController

20    public function __invoke(RequestInterface $request, ResponseInterface $response, array $args)
21    {
22        $request = $this->initRequest($request);
23        $noCacheResponse = \BO\Slim\Render::withLastModified($response, time(), '0');
24        return $this->readResponse($request, $noCacheResponse, $args);
25    }