1 | <?php |
||
8 | class Rule { |
||
9 | private $query; |
||
10 | private $pseudo; |
||
11 | private $depth; |
||
12 | private $index; |
||
13 | private $file; |
||
14 | private $line; |
||
15 | private $properties = []; |
||
16 | private $lastRun = 0; |
||
17 | |||
18 | const S = 1; |
||
19 | const M = 60; |
||
20 | const H = 3600; |
||
21 | const D = 86400; |
||
22 | |||
23 | |||
24 | public function __construct($query, $pseudo, $depth, $index, $file, $line, array $properties = []) { |
||
25 | $this->query = $query; |
||
26 | $this->pseudo = $pseudo; |
||
27 | $this->depth = $depth; |
||
28 | $this->index = $index; |
||
29 | $this->file = $file; |
||
30 | $this->line = $line; |
||
31 | $this->properties = $properties; |
||
32 | } |
||
33 | |||
34 | public function __get($name) { |
||
35 | return $this->$name; |
||
36 | } |
||
37 | |||
38 | public function __set($name, $value) { |
||
39 | $this->$name = $value; |
||
40 | } |
||
41 | |||
42 | public function touch() { |
||
43 | $this->lastRun = time(); |
||
44 | } |
||
45 | |||
46 | private function timeFrequency($frequency, $time = null) { |
||
|
|||
47 | if ($time === null) $time = time(); |
||
48 | |||
49 | $offset = $this->getUpdateFrequency(); |
||
50 | |||
51 | if ($time > $this->lastRun + $offset) return true; |
||
52 | else return false; |
||
53 | } |
||
54 | |||
55 | public function shouldRun($time = null) { |
||
64 | |||
65 | public function getUpdateFrequency() { |
||
66 | $frequency = isset($this->properties['update-frequency']) ? $this->properties['update-frequency']->read() : false; |
||
67 | |||
68 | if (empty($frequency)) return 0; |
||
69 | |||
77 | } |
||
78 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.