Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
TicketprinterWaitingnumberByCluster
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
11 / 11
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
8namespace BO\Zmsapi;
9
10use BO\Slim\Render;
11use BO\Mellon\Validator;
12use BO\Zmsdb\Ticketprinter as Query;
13use BO\Zmsdb\Cluster;
14use BO\Zmsdb\ProcessStatusQueued;
15
16class TicketprinterWaitingnumberByCluster 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    ) {
28        \BO\Zmsdb\Connection\Select::getWriteConnection();
29        $cluster = (new Cluster())->readEntity($args['id'], 0);
30        if (! $cluster) {
31            throw new Exception\Cluster\ClusterNotFound();
32        }
33
34        $scope = (new Cluster())->readScopeWithShortestWaitingTime($cluster->id, \App::$now);
35        $process = ProcessStatusQueued::init()->writeNewFromTicketprinter($scope, \App::$now);
36
37        $message = Response\Message::create($request);
38        $message->data = $process;
39
40        $response = Render::withLastModified($response, time(), '0');
41        $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode());
42        return $response;
43    }
44}