@@ -14,6 +14,10 @@ |
||
14 | 14 | const D = self::H*24; |
15 | 15 | |
16 | 16 | |
17 | + /** |
|
18 | + * @param string $query |
|
19 | + * @param integer $depth |
|
20 | + */ |
|
17 | 21 | public function __construct($query, $pseudo, $depth, $index, array $properties = []) { |
18 | 22 | $this->query = $query; |
19 | 23 | $this->pseudo = $pseudo; |
@@ -10,8 +10,8 @@ |
||
10 | 10 | |
11 | 11 | const S = 1; |
12 | 12 | const M = 60; |
13 | - const H = self::M*60; |
|
14 | - const D = self::H*24; |
|
13 | + const H = self::M * 60; |
|
14 | + const D = self::H * 24; |
|
15 | 15 | |
16 | 16 | |
17 | 17 | public function __construct($query, $pseudo, $depth, $index, array $properties = []) { |
@@ -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 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $cachedOutput = $this->loadTemplate(); |
32 | 32 | $xml = $cachedOutput['body']; |
33 | 33 | //To be a valid XML document it must have a root element, automatically wrap it in <template> to ensure it does |
34 | - $template = new Template($this->isValidDoc($xml) ? $xml : '<template>' . $xml . '</template>' ); |
|
34 | + $template = new Template($this->isValidDoc($xml) ? $xml : '<template>'.$xml.'</template>'); |
|
35 | 35 | $time = time(); |
36 | 36 | |
37 | 37 | foreach ($this->getRules($template) as $rule) { |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | |
60 | 60 | private function getRules($template) { |
61 | 61 | if (is_file($this->tss)) { |
62 | - $this->baseDir = dirname(realpath($this->tss)) . DIRECTORY_SEPARATOR; |
|
63 | - $key = $this->tss . $template->getPrefix() . $this->baseDir; |
|
62 | + $this->baseDir = dirname(realpath($this->tss)).DIRECTORY_SEPARATOR; |
|
63 | + $key = $this->tss.$template->getPrefix().$this->baseDir; |
|
64 | 64 | $rules = $this->cache->load($key, filemtime($this->tss)); |
65 | 65 | if (!$rules) return $this->cache->write($key, (new Sheet(file_get_contents($this->tss), $this->baseDir, $template->getPrefix()))->parse()); |
66 | 66 | else return $rules; |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | |
85 | 85 | private function getLocale() { |
86 | 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); |
|
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); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | public function registerProperties($object) { |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | $time = time(); |
36 | 36 | |
37 | 37 | foreach ($this->getRules($template) as $rule) { |
38 | - if ($rule->shouldRun($time)) $this->executeTssRule($rule, $template, $data); |
|
38 | + if ($rule->shouldRun($time)) { |
|
39 | + $this->executeTssRule($rule, $template, $data); |
|
40 | + } |
|
39 | 41 | } |
40 | 42 | |
41 | 43 | $output = $template->output($document); |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | private function executeTssRule($rule, $template, $data) { |
48 | 50 | $rule->touch(); |
49 | 51 | $hook = new Hook\Rule($rule->properties, new Hook\PseudoMatcher($rule->pseudo, $data), $data); |
50 | - foreach ($this->registeredProperties as $properties) $hook->registerProperties($properties); |
|
52 | + foreach ($this->registeredProperties as $properties) { |
|
53 | + $hook->registerProperties($properties); |
|
54 | + } |
|
51 | 55 | $template->addHook($rule->query, $hook); |
52 | 56 | } |
53 | 57 | |
@@ -55,8 +59,9 @@ discard block |
||
55 | 59 | if (trim($this->template)[0] !== '<') { |
56 | 60 | $xml = $this->cache->load($this->template, filemtime($this->template)); |
57 | 61 | return $xml ? $xml : $this->cache->write($this->template, ['body' => file_get_contents($this->template), 'headers' => []]); |
62 | + } else { |
|
63 | + return ['body' => $this->template, 'headers' => []]; |
|
58 | 64 | } |
59 | - else return ['body' => $this->template, 'headers' => []]; |
|
60 | 65 | } |
61 | 66 | |
62 | 67 | private function getRules($template) { |
@@ -64,10 +69,14 @@ discard block |
||
64 | 69 | $this->baseDir = dirname(realpath($this->tss)) . DIRECTORY_SEPARATOR; |
65 | 70 | $key = $this->tss . $template->getPrefix() . $this->baseDir; |
66 | 71 | $rules = $this->cache->load($key, filemtime($this->tss)); |
67 | - if (!$rules) return $this->cache->write($key, (new Sheet(file_get_contents($this->tss), $this->baseDir, $template->getPrefix()))->parse()); |
|
68 | - else return $rules; |
|
72 | + if (!$rules) { |
|
73 | + return $this->cache->write($key, (new Sheet(file_get_contents($this->tss), $this->baseDir, $template->getPrefix()))->parse()); |
|
74 | + } else { |
|
75 | + return $rules; |
|
76 | + } |
|
77 | + } else { |
|
78 | + return (new Sheet($this->tss, $this->baseDir, $template->getPrefix()))->parse(); |
|
69 | 79 | } |
70 | - else return (new Sheet($this->tss, $this->baseDir, $template->getPrefix()))->parse(); |
|
71 | 80 | } |
72 | 81 | |
73 | 82 | private function getBasicProperties($data, $locale, &$headers) { |
@@ -75,7 +84,9 @@ discard block |
||
75 | 84 | $basicProperties->registerFormatter(new Formatter\Number($locale)); |
76 | 85 | $basicProperties->registerFormatter(new Formatter\Date($locale)); |
77 | 86 | $basicProperties->registerFormatter(new Formatter\StringFormatter()); |
78 | - foreach ($this->formatters as $formatter) $basicProperties->registerFormatter($formatter); |
|
87 | + foreach ($this->formatters as $formatter) { |
|
88 | + $basicProperties->registerFormatter($formatter); |
|
89 | + } |
|
79 | 90 | |
80 | 91 | return isset($this->userCache) ? new Hook\Cache($basicProperties, $this->userCache) : $basicProperties; |
81 | 92 | } |
@@ -85,9 +96,13 @@ discard block |
||
85 | 96 | } |
86 | 97 | |
87 | 98 | private function getLocale() { |
88 | - if (is_array($this->locale)) return $this->locale; |
|
89 | - 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); |
|
90 | - else return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true); |
|
99 | + if (is_array($this->locale)) { |
|
100 | + return $this->locale; |
|
101 | + } else if (strlen($this->locale) > 0) { |
|
102 | + return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true); |
|
103 | + } else { |
|
104 | + return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true); |
|
105 | + } |
|
91 | 106 | } |
92 | 107 | |
93 | 108 | 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 |