Lines
100.00%
22 / 22
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Info | 100.00% | 22 / 22 | 100.00% | 1 / 1 | 4 | 100.00% | 1 / 1 | |||
| readResponse | 100.00% | 22 / 22 | 100.00% | 1 / 1 | 4 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * | |
| 5 | * @package Zmscalldisplay | |
| 6 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 7 | * | |
| 8 | */ | |
| 9 | ||
| 10 | namespace BO\Zmscalldisplay; | |
| 11 | ||
| 12 | use BO\Slim\Render; | |
| 13 | use BO\Zmsclient\Exception as ZmsclientException; | |
| 14 | use BO\Zmsclient\Psr7\RequestException; | |
| 15 | use Psr\Http\Message\RequestInterface; | |
| 16 | use Psr\Http\Message\ResponseInterface; | |
| 17 | use BO\Zmsentities\Collection\QueueList; | |
| 18 | ||
| 19 | class Info extends BaseController | |
| 20 | { | |
| 21 | /** | |
| 22 | * @SuppressWarnings(UnusedFormalParameter) | |
| 23 | * @return ResponseInterface | |
| 24 | * @psalm-api | |
| 25 | */ | |
| 26 | public function readResponse( | |
| 27 | RequestInterface $request, | |
| 28 | ResponseInterface $response | |
| 29 | ) { | |
| 30 | $calldisplay = new Helper\Calldisplay($request); | |
| 31 | try { | |
| 32 | $queueListFull = \App::$http | |
| 33 | ->readPostResult('/calldisplay/queue/', $calldisplay->getEntity(false)) | |
| 34 | ->getCollection(); | |
| 35 | } catch (ZmsclientException | RequestException $exception) { | |
| 36 | return $this->skipRefresh($response, $exception, 'Calldisplay waitinginfo refresh skipped'); | |
| 37 | } | |
| 38 | ||
| 39 | $filteredQueue = $queueListFull | |
| 40 | ->withoutStatus(QueueList::STATUS_FAKE) | |
| 41 | ->getCountWithWaitingTime(); | |
| 42 | ||
| 43 | $lastClient = $filteredQueue->getLast(); | |
| 44 | $waitingTimeFull = $lastClient ? $lastClient->waitingTimeEstimate : 0; | |
| 45 | $waitingTimeOptimistic = $lastClient ? $lastClient->waitingTimeOptimistic : 0; | |
| 46 | ||
| 47 | return Render::withHtml( | |
| 48 | $response, | |
| 49 | 'element/tempWaitingValues.twig', | |
| 50 | array( | |
| 51 | 'calldisplay' => $calldisplay, | |
| 52 | 'waitingClients' => $filteredQueue->count(), | |
| 53 | 'waitingTime' => $waitingTimeFull, | |
| 54 | 'waitingTimeOptimistic' => $waitingTimeOptimistic | |
| 55 | ) | |
| 56 | ); | |
| 57 | } | |
| 58 | } |