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/Sheet.php 1 patch
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -11,6 +11,9 @@  discard block
 block discarded – undo
11 11
 	private $baseDir;
12 12
 	private $prefix;
13 13
 
14
+	/**
15
+	 * @param string $tss
16
+	 */
14 17
 	public function __construct($tss, $baseDir, $prefix = '') {
15 18
 		$this->tss = $this->stripComments($tss);
16 19
 		$this->baseDir = $baseDir;
@@ -36,12 +39,20 @@  discard block
 block discarded – undo
36 39
 		return $rules;
37 40
 	}
38 41
 
42
+	/**
43
+	 * @param string $selector
44
+	 * @param integer $index
45
+	 */
39 46
 	private function CssToRule($selector, $index) {
40 47
 		$xPath = new CssToXpath($selector, $this->prefix);
41 48
 		$rule = new Rule($xPath->getXpath(), $xPath->getPseudo(), $xPath->getDepth(), $index++);
42 49
 		return $rule;
43 50
 	}
44 51
 
52
+	/**
53
+	 * @param string $selector
54
+	 * @param Rule $newRule
55
+	 */
45 56
 	private function writeRule($rules, $selector, $newRule) {
46 57
 		if (isset($rules[$selector])) $newRule->properties = array_merge($rules[$selector], $newRule->properties);
47 58
 		$rules[$selector] = $newRule;
@@ -49,6 +60,10 @@  discard block
 block discarded – undo
49 60
 		return $rules;
50 61
 	}
51 62
 
63
+	/**
64
+	 * @param integer $pos
65
+	 * @param integer $next
66
+	 */
52 67
 	private function processingInstructions($tss, $pos, $next) {
53 68
 		$rules = [];
54 69
 		while (($atPos = strpos($tss, '@', $pos)) !== false) {
@@ -87,6 +102,9 @@  discard block
 block discarded – undo
87 102
 		return $str;
88 103
 	}
89 104
 
105
+	/**
106
+	 * @param string $str
107
+	 */
90 108
 	private function getProperties($str) {
91 109
 		$stringExtractor = new \Transphporm\StringExtractor($str);
92 110
 		$rules = explode(';', $stringExtractor);
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.