1 | <?php |
||
7 | class Timer implements TimerInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var float |
||
11 | */ |
||
12 | const MIN_INTERVAL = 1e-6; |
||
13 | |||
14 | /** |
||
15 | * @var LoopModelInterface |
||
16 | */ |
||
17 | protected $loop; |
||
18 | |||
19 | /** |
||
20 | * @var float |
||
21 | */ |
||
22 | protected $interval; |
||
23 | |||
24 | /** |
||
25 | * @var callable |
||
26 | */ |
||
27 | protected $callback; |
||
28 | |||
29 | /** |
||
30 | * @var bool |
||
31 | */ |
||
32 | protected $periodic; |
||
33 | |||
34 | /** |
||
35 | * @var mixed|null |
||
36 | */ |
||
37 | protected $data; |
||
38 | |||
39 | /** |
||
40 | * @param LoopModelInterface $loop |
||
41 | * @param $interval |
||
42 | * @param callable $callback |
||
43 | * @param bool $periodic |
||
44 | * @param mixed|null $data |
||
45 | */ |
||
46 | 42 | public function __construct(LoopModelInterface $loop, $interval, callable $callback, $periodic = false, $data = null) |
|
59 | |||
60 | /** |
||
61 | * |
||
62 | */ |
||
63 | 26 | public function __destruct() |
|
71 | |||
72 | /** |
||
73 | * @override |
||
74 | * @inheritDoc |
||
75 | */ |
||
76 | 1 | public function getLoop() |
|
80 | |||
81 | /** |
||
82 | * @override |
||
83 | * @inheritDoc |
||
84 | */ |
||
85 | 22 | public function getInterval() |
|
89 | |||
90 | /** |
||
91 | * @override |
||
92 | * @inheritDoc |
||
93 | */ |
||
94 | 5 | public function getCallback() |
|
98 | |||
99 | /** |
||
100 | * @override |
||
101 | * @inheritDoc |
||
102 | */ |
||
103 | 2 | public function getData() |
|
107 | |||
108 | /** |
||
109 | * @override |
||
110 | * @inheritDoc |
||
111 | */ |
||
112 | 1 | public function setData($data) |
|
116 | |||
117 | /** |
||
118 | * @override |
||
119 | * @inheritDoc |
||
120 | */ |
||
121 | 6 | public function isPeriodic() |
|
125 | |||
126 | /** |
||
127 | * @override |
||
128 | * @inheritDoc |
||
129 | */ |
||
130 | 1 | public function isActive() |
|
134 | |||
135 | /** |
||
136 | * @override |
||
137 | * @inheritDoc |
||
138 | */ |
||
139 | 1 | public function cancel() |
|
146 | } |
||
147 |