@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | if ($rule->shouldRun($time)) { |
39 | 39 | $rule->touch(); |
40 | 40 | $hook = new Hook\Rule($rule->properties, new Hook\PseudoMatcher($rule->pseudo, $data), $data); |
41 | - foreach ($this->registeredProperties as $properties) $hook->registerProperties($properties); |
|
41 | + foreach ($this->registeredProperties as $properties) { |
|
42 | + $hook->registerProperties($properties); |
|
43 | + } |
|
42 | 44 | $template->addHook($rule->query, $hook); |
43 | 45 | } |
44 | 46 | } |
@@ -53,8 +55,9 @@ discard block |
||
53 | 55 | if (trim($this->template)[0] !== '<') { |
54 | 56 | $xml = $this->cache->load($this->template, filemtime($this->template)); |
55 | 57 | return $xml ? $xml : $this->cache->write($this->template, ['body' => file_get_contents($this->template), 'headers' => []]); |
58 | + } else { |
|
59 | + return ['body' => $this->template, 'headers' => []]; |
|
56 | 60 | } |
57 | - else return ['body' => $this->template, 'headers' => []]; |
|
58 | 61 | } |
59 | 62 | |
60 | 63 | private function getRules($template) { |
@@ -62,10 +65,14 @@ discard block |
||
62 | 65 | $this->baseDir = dirname(realpath($this->tss)) . DIRECTORY_SEPARATOR; |
63 | 66 | $key = $this->tss . $template->getPrefix() . $this->baseDir; |
64 | 67 | $rules = $this->cache->load($key, filemtime($this->tss)); |
65 | - if (!$rules) return $this->cache->write($key, (new Sheet(file_get_contents($this->tss), $this->baseDir, $template->getPrefix()))->parse()); |
|
66 | - else return $rules; |
|
68 | + if (!$rules) { |
|
69 | + return $this->cache->write($key, (new Sheet(file_get_contents($this->tss), $this->baseDir, $template->getPrefix()))->parse()); |
|
70 | + } else { |
|
71 | + return $rules; |
|
72 | + } |
|
73 | + } else { |
|
74 | + return (new Sheet($this->tss, $this->baseDir, $template->getPrefix()))->parse(); |
|
67 | 75 | } |
68 | - else return (new Sheet($this->tss, $this->baseDir, $template->getPrefix()))->parse(); |
|
69 | 76 | } |
70 | 77 | |
71 | 78 | private function getBasicProperties($data, $locale, &$headers) { |
@@ -73,7 +80,9 @@ discard block |
||
73 | 80 | $basicProperties->registerFormatter(new Formatter\Number($locale)); |
74 | 81 | $basicProperties->registerFormatter(new Formatter\Date($locale)); |
75 | 82 | $basicProperties->registerFormatter(new Formatter\StringFormatter()); |
76 | - foreach ($this->formatters as $formatter) $basicProperties->registerFormatter($formatter); |
|
83 | + foreach ($this->formatters as $formatter) { |
|
84 | + $basicProperties->registerFormatter($formatter); |
|
85 | + } |
|
77 | 86 | |
78 | 87 | return isset($this->userCache) ? new Hook\Cache($basicProperties, $this->userCache) : $basicProperties; |
79 | 88 | } |
@@ -83,9 +92,13 @@ discard block |
||
83 | 92 | } |
84 | 93 | |
85 | 94 | private function getLocale() { |
86 | - if (is_array($this->locale)) return $this->locale; |
|
87 | - else if (strlen($this->locale) > 0) return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true); |
|
88 | - else return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true); |
|
95 | + if (is_array($this->locale)) { |
|
96 | + return $this->locale; |
|
97 | + } else if (strlen($this->locale) > 0) { |
|
98 | + return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true); |
|
99 | + } else { |
|
100 | + return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true); |
|
101 | + } |
|
89 | 102 | } |
90 | 103 | |
91 | 104 | public function registerProperties($object) { |
@@ -20,7 +20,8 @@ |
||
20 | 20 | public function load($key, $modified = 0) { |
21 | 21 | if (isset($this->cache[$key]) && $this->cache[$key]['timestamp'] >= $modified) { |
22 | 22 | return $this->cache[$key]['content']; |
23 | + } else { |
|
24 | + return false; |
|
23 | 25 | } |
24 | - else return false; |
|
25 | 26 | } |
26 | 27 | } |
27 | 28 | \ No newline at end of file |
@@ -38,8 +38,11 @@ |
||
38 | 38 | if (isset($this->properties['update-frequency']) && $this->lastRun !== 0) { |
39 | 39 | $frequency = $this->properties['update-frequency']; |
40 | 40 | $static = ['always' => true, 'never' => false]; |
41 | - if (isset($static[$frequency])) return $static[$frequency]; |
|
41 | + if (isset($static[$frequency])) { |
|
42 | + return $static[$frequency]; |
|
43 | + } |
|
44 | + } else { |
|
45 | + return true; |
|
42 | 46 | } |
43 | - else return true; |
|
44 | 47 | } |
45 | 48 | } |
46 | 49 | \ No newline at end of file |