1 | <?php |
||
17 | class Cron |
||
18 | { |
||
19 | /** @var array */ |
||
20 | protected $jobs = []; |
||
21 | |||
22 | /** @var int */ |
||
23 | protected $now; |
||
24 | |||
25 | /** @var array|null Null if not intialized */ |
||
26 | private $lastRuns = null; |
||
27 | |||
28 | /** |
||
29 | * Constructor |
||
30 | */ |
||
31 | public function __construct() |
||
35 | |||
36 | /** |
||
37 | * Add cron job |
||
38 | * |
||
39 | * @param string $id unique ID for cron job |
||
40 | * @param string $due due intervall |
||
41 | * @param callable $func cron job |
||
42 | * @return self |
||
43 | */ |
||
44 | public function addCronJob(string $id, string $due, callable $func): self |
||
50 | |||
51 | /** |
||
52 | * Run cron jobs |
||
53 | * |
||
54 | * @return void |
||
55 | */ |
||
56 | public function execute() |
||
76 | |||
77 | /** |
||
78 | * Clear history |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | public function clearHistory() |
||
88 | |||
89 | /** |
||
90 | * Get last cron runs |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | protected function getLastRuns(): array |
||
102 | |||
103 | /** |
||
104 | * Create new cache data |
||
105 | * |
||
106 | * @return void |
||
107 | */ |
||
108 | protected function saveLastRuns(): void |
||
112 | } |
||
113 |