Lines 100.00% 20 / 20
Functions and Methods 100.00% 5 / 5
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
Queue 100.00% 20 / 20 100.00% 5 / 5 6 100.00% 1 / 1
 getDefaults 100.00% 11 / 11 100.00% 1 / 1 1
 setProcess 100.00% 2 / 2 100.00% 1 / 1 1
 getProcess 100.00% 5 / 5 100.00% 1 / 1 2
 withReference 100.00% 1 / 1 100.00% 1 / 1 1
 __clone 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3namespace BO\Zmsentities;
4
5class Queue extends Schema\Entity implements Helper\NoSanitize
6{
7    public const string PRIMARY = 'arrivalTime';
8
9    public static $schema = "queue.json";
10
11    protected ?Process $process = null;
12
13    /**
14     * @return (int|null)[]
15     *
16     */
17    #[\Override]
18    public function getDefaults()
19    {
20        return [
21            "arrivalTime" => 0,
22            "callCount" => 0,
23            "callTime" => 0,
24            "number" => 0,
25            "waitingTimeEstimate" => 0,
26            "waitingTimeOptimistic" => 0,
27            "waitingTime" => 0,
28            "wayTime" => 0,
29            "priority" => null
30        ];
31    }
32
33    public function setProcess(Process $parentProcess): static
34    {
35        $this->process = $parentProcess;
36        return $this;
37    }
38
39    public function getProcess(): Process|null
40    {
41        if ($this->process instanceof Process) {
42            $process = clone $this->process;
43            $process->queue = clone $this;
44            return $process;
45        }
46        return null;
47    }
48
49    #[\Override]
50    public function withReference($additionalData = []): self|array
51    {
52        return clone $this;
53    }
54
55    /**
56     * Keep empty, no sub-instances
57     * ATTENTION: Keep highly optimized, time critical function
58     */
59    #[\Override]
60    public function __clone()
61    {
62    }
63}