Lines
100.00%
17 / 17
Methods
100.00%
7 / 7
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __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 | ||
| 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 $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|null $process): QueueList | |
| 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 | } |