Conditions | 5 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
37 | public function shouldRun($time) { |
||
38 | if (isset($this->properties['update-frequency']) && $this->lastRun !== 0) { |
||
39 | $frequency = $this->properties['update-frequency']; |
||
40 | $static = ['always' => true, 'never' => false]; |
||
41 | if (isset($static[$frequency])) return $static[$frequency]; |
||
42 | |||
43 | $num = (int) $frequency; |
||
44 | $unit = strtoupper(trim(str_replace($num, '', $frequency))); |
||
45 | |||
46 | $offset = $num * constant(self::class . '::' . $unit); |
||
47 | |||
48 | if ($time > $this->lastRun + $offset) return true; |
||
49 | else return false; |
||
50 | |||
51 | } |
||
52 | else return true; |
||
53 | } |
||
54 | } |