Completed
Push — master ( 534878...ea6b08 )
by Tom
02:29
created
src/Rule.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -14,6 +14,10 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@
 block discarded – undo
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 = []) {
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,11 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Builder.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,7 +38,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
src/FileCache.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
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
Please login to merge, or discard this patch.