Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
17 / 17 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
| QueueListHelper | |
100.00% |
17 / 17 |
|
100.00% |
7 / 7 |
12 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getList | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getEstimatedWaitingTime | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOptimisticWaitingTime | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getClientsBefore | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| createFullList | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| createQueueList | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
5 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * |
| 5 | * @package Zmsadmin |
| 6 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | namespace BO\Zmsticketprinter\Helper; |
| 11 | |
| 12 | use BO\Mellon\Validator; |
| 13 | use BO\Zmsentities\Collection\QueueList; |
| 14 | |
| 15 | class QueueListHelper |
| 16 | { |
| 17 | protected static $fullList = null; |
| 18 | |
| 19 | protected static $queueList = null; |
| 20 | |
| 21 | protected static $status = ['confirmed', 'queued', 'reserved', 'fake']; |
| 22 | |
| 23 | public function __construct(\BO\Zmsentities\Scope $scope, \BO\Zmsentities\Process $process = null) |
| 24 | { |
| 25 | static::$fullList = static::createFullList($scope); |
| 26 | static::$queueList = static::createQueueList($process); |
| 27 | } |
| 28 | |
| 29 | public static function getList() |
| 30 | { |
| 31 | return static::$queueList; |
| 32 | } |
| 33 | |
| 34 | public static function getEstimatedWaitingTime() |
| 35 | { |
| 36 | return static::getList()->getFakeOrLastWaitingnumber()->waitingTimeEstimate; |
| 37 | } |
| 38 | |
| 39 | public static function getOptimisticWaitingTime() |
| 40 | { |
| 41 | return static::getList()->getFakeOrLastWaitingnumber()->waitingTimeOptimistic; |
| 42 | } |
| 43 | |
| 44 | public static function getClientsBefore() |
| 45 | { |
| 46 | $entity = static::getList()->getFakeOrLastWaitingnumber(); |
| 47 | return (static::getList()->getQueuePositionByNumber($entity->number)); |
| 48 | } |
| 49 | |
| 50 | protected static function createFullList($scope) |
| 51 | { |
| 52 | $fullList = \App::$http |
| 53 | ->readGetResult('/scope/' . $scope->getId() . '/queue/') |
| 54 | ->getCollection(); |
| 55 | return ($fullList) ? $fullList : new QueueList(); |
| 56 | } |
| 57 | |
| 58 | protected static function createQueueList($process) |
| 59 | { |
| 60 | $queueList = new QueueList(); |
| 61 | if (static::$fullList->count()) { |
| 62 | foreach (static::$fullList->withStatus(self::$status) as $entity) { |
| 63 | if (! $process || $entity->number != $process->queue->number) { |
| 64 | $queueList->addEntity($entity); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | return $queueList; |
| 69 | } |
| 70 | } |