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 | use BO\Zmsentities\Scope; |
| 15 | use BO\Zmsentities\Process; |
| 16 | |
| 17 | class QueueListHelper |
| 18 | { |
| 19 | protected static $fullList = null; |
| 20 | |
| 21 | protected static $queueList = null; |
| 22 | |
| 23 | protected static $status = ['confirmed', 'queued', 'reserved', 'fake']; |
| 24 | |
| 25 | public function __construct(Scope $scope, Process $process = null) |
| 26 | { |
| 27 | static::$fullList = static::createFullList($scope); |
| 28 | static::$queueList = static::createQueueList($process); |
| 29 | } |
| 30 | |
| 31 | public static function getList() |
| 32 | { |
| 33 | return static::$queueList; |
| 34 | } |
| 35 | |
| 36 | public static function getEstimatedWaitingTime() |
| 37 | { |
| 38 | return static::getList()->getFakeOrLastWaitingnumber()->waitingTimeEstimate; |
| 39 | } |
| 40 | |
| 41 | public static function getOptimisticWaitingTime() |
| 42 | { |
| 43 | return static::getList()->getFakeOrLastWaitingnumber()->waitingTimeOptimistic; |
| 44 | } |
| 45 | |
| 46 | public static function getClientsBefore() |
| 47 | { |
| 48 | $entity = static::getList()->getFakeOrLastWaitingnumber(); |
| 49 | return (static::getList()->getQueuePositionByNumber($entity->number)); |
| 50 | } |
| 51 | |
| 52 | protected static function createFullList($scope) |
| 53 | { |
| 54 | $fullList = \App::$http |
| 55 | ->readGetResult('/scope/' . $scope->getId() . '/queue/') |
| 56 | ->getCollection(); |
| 57 | return ($fullList) ? $fullList : new QueueList(); |
| 58 | } |
| 59 | |
| 60 | protected static function createQueueList($process) |
| 61 | { |
| 62 | $queueList = new QueueList(); |
| 63 | if (static::$fullList->count()) { |
| 64 | foreach (static::$fullList->withStatus(self::$status) as $entity) { |
| 65 | if (! $process || $entity->number != $process->queue->number) { |
| 66 | $queueList->addEntity($entity); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | return $queueList; |
| 71 | } |
| 72 | } |