Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
18 / 18 |
|
100.00% |
10 / 10 |
CRAP | |
100.00% |
1 / 1 |
QueueListHelper | |
100.00% |
18 / 18 |
|
100.00% |
10 / 10 |
13 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getList | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFullList | |
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 | |||
getWaitingCount | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
getWaitingClientsEffective | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getWaitingClientsBeforeNext | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
createFullList | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
createQueueList | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * |
5 | * @package Zmsadmin |
6 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
7 | * |
8 | */ |
9 | |
10 | namespace BO\Zmsadmin\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 = ['preconfirmed', 'confirmed', 'queued', 'reserved', 'deleted', 'fake']; |
22 | |
23 | protected static $missedStatus = ['missed']; |
24 | |
25 | protected static $parkedStatus = ['parked']; |
26 | |
27 | public function __construct(ClusterHelper $clusterHelper, $selectedDate) |
28 | { |
29 | $dateTime = (new \DateTimeImmutable($selectedDate))->modify(\App::$now->format('H:i:s')); |
30 | static::$fullList = static::createFullList($clusterHelper, $dateTime); |
31 | static::$queueList = static::createQueueList(); |
32 | } |
33 | |
34 | public static function getList() |
35 | { |
36 | return static::$queueList; |
37 | } |
38 | |
39 | public static function getFullList() |
40 | { |
41 | return static::$fullList; |
42 | } |
43 | |
44 | public static function getEstimatedWaitingTime() |
45 | { |
46 | return self::getList()->getFakeOrLastWaitingnumber()->waitingTimeEstimate; |
47 | } |
48 | |
49 | public static function getOptimisticWaitingTime() |
50 | { |
51 | return self::getList()->getFakeOrLastWaitingnumber()->waitingTimeOptimistic; |
52 | } |
53 | |
54 | public static function getWaitingCount() |
55 | { |
56 | // return count -1 because of faked entry |
57 | return (self::getList()->count()) ? (self::getList()->withoutStatus(['fake'])->count()) : 0; |
58 | } |
59 | |
60 | public static function getWaitingClientsEffective() |
61 | { |
62 | $effectiveStatus = self::$status; |
63 | unset($effectiveStatus['fake']); |
64 | return self::getList()->withoutStatus(['fake'])->getCountWithWaitingTime()->count(); |
65 | } |
66 | |
67 | public static function getWaitingClientsBeforeNext() |
68 | { |
69 | $entity = self::getList()->getFakeOrLastWaitingnumber(); |
70 | return (self::getList()->getQueuePositionByNumber($entity->number)); |
71 | } |
72 | |
73 | protected static function createFullList($clusterHelper, $dateTime) |
74 | { |
75 | $fullList = $clusterHelper->getProcessList($dateTime->format('Y-m-d')); |
76 | return ($fullList->count()) ? $fullList->toQueueList($dateTime) : new QueueList(); |
77 | } |
78 | |
79 | protected static function createQueueList() |
80 | { |
81 | return (static::$fullList->count()) ? |
82 | static::$fullList->withStatus(self::$status) : |
83 | new QueueList(); |
84 | } |
85 | } |