Lines 100.00% 22 / 22
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 readResponse 100.00% 19 / 19 100.00% 1 / 1 4
 [BO\Zmsbackend\Api\BaseController] __invoke 100.00% 3 / 3 100.00% 1 / 1 1
14class ProcessByQueueNumber extends \BO\Zmsbackend\Api\BaseController
15{
16    /**
17     * @SuppressWarnings(Param)
18     * @return \Psr\Http\Message\ResponseInterface
19     */
20    #[\Override]
21    public function readResponse(
22        \Psr\Http\Message\RequestInterface $request,
23        \Psr\Http\Message\ResponseInterface $response,
24        array $args
25    ) {
26        $resolveReferences = Validator::param('resolveReferences')->isNumber()->setDefault(0)->getValue();
27        $scope = (new \BO\Zmsbackend\Scope\Service\Scope())->readWithWorkstationCount(
28            $args['id'],
29            \App::$now,
30            ($resolveReferences > 0) ? $resolveReferences - 1 : 0
31        );
32        if (! $scope) {
33            throw new \BO\Zmsbackend\Scope\Exception\ScopeNotFound();
34        }
35        $queueList = (new \BO\Zmsbackend\Scope\Service\Scope())->readQueueListWithWaitingTime($scope, \App::$now, $resolveReferences + 1);
36        $process = $queueList->getQueueByNumber($args['number']);
37        if ($process) {
38            $process = $process->getProcess();
39            $process->scope = $scope;
40        } else {
41            throw new \BO\Zmsbackend\Process\Exception\ProcessByQueueNumberNotFound();
42        }
43
44        $message = \BO\Zmsbackend\Api\Response\Message::create($request);
45        $message->data = $process;
46
47        $response = Render::withLastModified($response, time(), '0');
48        $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode());
49        return $response;
50    }
51}

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    }