Total Complexity | 8 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | abstract class CronJob implements CronJobInterface |
||
6 | { |
||
7 | /** |
||
8 | * Swoole timer id |
||
9 | * @var int |
||
10 | */ |
||
11 | protected $timerId; |
||
12 | |||
13 | /** |
||
14 | * The interval of Job in millisecond |
||
15 | * @var int |
||
16 | */ |
||
17 | protected $interval; |
||
18 | |||
19 | /** |
||
20 | * Whether run immediately after start |
||
21 | * @var bool |
||
22 | */ |
||
23 | protected $isImmediate; |
||
24 | |||
25 | /** |
||
26 | * CronJob constructor. |
||
27 | * Optional: |
||
28 | * argument 1 is interval, int ms, default null, overridden by method interval() |
||
29 | * argument 2 is isImmediate, bool, default false, overridden by method isImmediate() |
||
30 | */ |
||
31 | public function __construct() |
||
32 | { |
||
33 | $args = func_get_args(); |
||
34 | if (array_key_exists(0, $args)) { |
||
35 | $this->interval = $args[0]; |
||
36 | } |
||
37 | if (array_key_exists(1, $args)) { |
||
38 | $this->isImmediate = $args[1]; |
||
39 | } |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @return int |
||
44 | */ |
||
45 | public function interval() |
||
46 | { |
||
47 | return $this->interval; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return bool $isImmediate |
||
52 | */ |
||
53 | public function isImmediate() |
||
54 | { |
||
55 | return $this->isImmediate; |
||
56 | } |
||
57 | |||
58 | public function setTimerId($timerId) |
||
59 | { |
||
60 | $this->timerId = $timerId; |
||
61 | } |
||
62 | |||
63 | public function stop() |
||
67 | } |
||
68 | } |
||
69 | |||
70 | } |