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 String
21     */
22    public function readResponse(
23        \Psr\Http\Message\RequestInterface $request,
24        \Psr\Http\Message\ResponseInterface $response,
25        array $args
26    ) {
27        \BO\Zmsdb\Connection\Select::getWriteConnection();
28        $cluster = (new Cluster())->readEntity($args['id'], 0);
29        if (! $cluster) {
30            throw new Exception\Cluster\ClusterNotFound();
31        }
32
33        $scope = (new Cluster())->readScopeWithShortestWaitingTime($cluster->id, \App::$now);
34        $process = ProcessStatusQueued::init()->writeNewFromTicketprinter($scope, \App::$now);
35
36        $message = Response\Message::create($request);
37        $message->data = $process;
38
39        $response = Render::withLastModified($response, time(), '0');
40        $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode());
41        return $response;
42    }
43}