Lines
100.00%
21 / 21
Methods
100.00%
10 / 10
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __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% | 6 / 6 | 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 | ||
| 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 | /** @psalm-api */ | |
| 45 | public static function getEstimatedWaitingTime() | |
| 46 | { | |
| 47 | return self::getList()->getFakeOrLastWaitingnumber()->waitingTimeEstimate; | |
| 48 | } | |
| 49 | ||
| 50 | /** @psalm-api */ | |
| 51 | public static function getOptimisticWaitingTime() | |
| 52 | { | |
| 53 | return self::getList()->getFakeOrLastWaitingnumber()->waitingTimeOptimistic; | |
| 54 | } | |
| 55 | ||
| 56 | public static function getWaitingCount() | |
| 57 | { | |
| 58 | // return count -1 because of faked entry | |
| 59 | return (self::getList()->count()) ? (self::getList()->withoutStatus(['fake'])->count()) : 0; | |
| 60 | } | |
| 61 | ||
| 62 | /** @psalm-api */ | |
| 63 | public static function getWaitingClientsEffective() | |
| 64 | { | |
| 65 | $effectiveStatus = self::$status; | |
| 66 | unset($effectiveStatus['fake']); | |
| 67 | ||
| 68 | return self::getList() | |
| 69 | ->withoutStatus(['fake']) | |
| 70 | ->getCountWithWaitingTime(\App::$now) | |
| 71 | ->count(); | |
| 72 | } | |
| 73 | ||
| 74 | /** @psalm-api */ | |
| 75 | public static function getWaitingClientsBeforeNext() | |
| 76 | { | |
| 77 | $entity = self::getList()->getFakeOrLastWaitingnumber(); | |
| 78 | return (self::getList()->getQueuePositionByNumber($entity->number)); | |
| 79 | } | |
| 80 | ||
| 81 | protected static function createFullList(ClusterHelper $clusterHelper, \DateTimeImmutable|false $dateTime) | |
| 82 | { | |
| 83 | $fullList = $clusterHelper->getProcessList($dateTime->format('Y-m-d')); | |
| 84 | return ($fullList->count()) ? $fullList->toQueueList($dateTime) : new QueueList(); | |
| 85 | } | |
| 86 | ||
| 87 | protected static function createQueueList() | |
| 88 | { | |
| 89 | return (static::$fullList->count()) ? | |
| 90 | static::$fullList->withStatus(self::$status) : | |
| 91 | new QueueList(); | |
| 92 | } | |
| 93 | } |