Completed
Pull Request — master (#236)
by
unknown
03:52
created
src/FunctionSet.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,11 +26,12 @@
 block discarded – undo
26 26
 	private function getArgs0($name, $args) {
27 27
 		if (isset($this->functions[$name]) && !($this->functions[$name] instanceof TSSFunction\Data)) {
28 28
 			$tokens = $args[0];
29
-			if ($tokens->count() == 0) return [];
29
+			if ($tokens->count() == 0) {
30
+				return [];
31
+			}
30 32
 			$parser = new \Transphporm\Parser\Value($this);
31 33
 			return $parser->parseTokens($tokens, $this->elementData->getData($this->element));
32
-		}
33
-		else {
34
+		} else {
34 35
 			return iterator_to_array($args[0]);
35 36
 		}
36 37
 
Please login to merge, or discard this patch.
src/Parser/Sheet.php 3 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@  discard block
 block discarded – undo
30 30
 		return $rules;
31 31
 	}
32 32
 
33
+	/**
34
+	 * @param integer $indexStart
35
+	 */
33 36
 	private function parseTokens($indexStart) {
34 37
 		$this->rules = [];
35 38
 		foreach (new TokenFilterIterator($this->tss, [Tokenizer::WHITESPACE]) as $token) {
@@ -55,6 +58,10 @@  discard block
 block discarded – undo
55 58
 		if (empty($rules) && count($this->tss) > 0) throw new \Exception('No TSS rules parsed');
56 59
 	}
57 60
 
61
+	/**
62
+	 * @param Tokens $selector
63
+	 * @param integer $index
64
+	 */
58 65
 	private function CssToRules($selector, $index, $properties, $line) {
59 66
 		$parts = $selector->trim()->splitOnToken(Tokenizer::ARG);
60 67
 		$rules = [];
@@ -78,6 +85,9 @@  discard block
 block discarded – undo
78 85
 		return $rules;
79 86
 	}
80 87
 
88
+	/**
89
+	 * @param integer $indexStart
90
+	 */
81 91
 	private function processingInstructions($token, $indexStart) {
82 92
 		if ($token['type'] !== Tokenizer::AT_SIGN) return false;
83 93
 		$tokens = $this->tss->from(Tokenizer::AT_SIGN, false)->to(Tokenizer::SEMI_COLON, false);
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -104,15 +104,15 @@
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	private function getProperties($tokens) {
107
-        $rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON);
107
+		$rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON);
108 108
 
109
-        $return = [];
110
-        foreach ($rules as $rule) {
111
-            $name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read();
112
-            $tokens = $rule->from(Tokenizer::COLON)->trim();
113
-            if (count($tokens) > 0) $return[$name] = $rule->from(Tokenizer::COLON)->trim();
114
-        }
109
+		$return = [];
110
+		foreach ($rules as $rule) {
111
+			$name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read();
112
+			$tokens = $rule->from(Tokenizer::COLON)->trim();
113
+			if (count($tokens) > 0) $return[$name] = $rule->from(Tokenizer::COLON)->trim();
114
+		}
115 115
 
116
-        return $return;
117
-    }
116
+		return $return;
117
+	}
118 118
 }
Please login to merge, or discard this patch.
Braces   +17 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 	}
26 26
 
27 27
 	public function parse($indexStart = 0) {
28
-		if (!empty($this->rules)) return $this->rules['rules'];
28
+		if (!empty($this->rules)) {
29
+			return $this->rules['rules'];
30
+		}
29 31
 		$rules = $this->parseTokens($indexStart);
30 32
 		$this->checkError($rules);
31 33
 		return $rules;
@@ -36,8 +38,9 @@  discard block
 block discarded – undo
36 38
 		foreach (new TokenFilterIterator($this->tss, [Tokenizer::WHITESPACE]) as $token) {
37 39
 			if ($processing = $this->processingInstructions($token, count($this->rules)+$indexStart)) {
38 40
 				$this->rules = array_merge($this->rules, $processing);
41
+			} else if (!in_array($token['type'], [Tokenizer::NEW_LINE, Tokenizer::AT_SIGN])) {
42
+				$this->addRules($token, $indexStart++);
39 43
 			}
40
-			else if (!in_array($token['type'], [Tokenizer::NEW_LINE, Tokenizer::AT_SIGN])) $this->addRules($token, $indexStart++);
41 44
 		}
42 45
 
43 46
 		return $this->rules;
@@ -47,13 +50,17 @@  discard block
 block discarded – undo
47 50
 		$selector = $this->tss->from($token['type'], true)->to(Tokenizer::OPEN_BRACE);
48 51
 
49 52
 		$this->tss->skip(count($selector));
50
-		if (count($selector) === 0) return;
53
+		if (count($selector) === 0) {
54
+			return;
55
+		}
51 56
 		$newRules = $this->cssToRules($selector, count($this->rules)+$indexStart, $this->getProperties($this->tss->current()['value']), $token['line']);
52 57
 		$this->rules = $this->writeRule($this->rules, $newRules);
53 58
 	}
54 59
 
55 60
 	private function checkError($rules) {
56
-		if (empty($rules) && count($this->tss) > 0) throw new \Exception('No TSS rules parsed');
61
+		if (empty($rules) && count($this->tss) > 0) {
62
+			throw new \Exception('No TSS rules parsed');
63
+		}
57 64
 	}
58 65
 
59 66
 	private function CssToRules($selector, $index, $properties, $line) {
@@ -80,7 +87,9 @@  discard block
 block discarded – undo
80 87
 	}
81 88
 
82 89
 	private function processingInstructions($token, $indexStart) {
83
-		if ($token['type'] !== Tokenizer::AT_SIGN) return false;
90
+		if ($token['type'] !== Tokenizer::AT_SIGN) {
91
+			return false;
92
+		}
84 93
 		$tokens = $this->tss->from(Tokenizer::AT_SIGN, false)->to(Tokenizer::SEMI_COLON, false);
85 94
 		$funcName = $tokens->from(Tokenizer::NAME, true)->read();
86 95
 		$funcToks = $tokens->from(Tokenizer::NAME);
@@ -110,7 +119,9 @@  discard block
 block discarded – undo
110 119
         foreach ($rules as $rule) {
111 120
             $name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read();
112 121
             $tokens = $rule->from(Tokenizer::COLON)->trim();
113
-            if (count($tokens) > 0) $return[$name] = $rule->from(Tokenizer::COLON)->trim();
122
+            if (count($tokens) > 0) {
123
+            	$return[$name] = $rule->from(Tokenizer::COLON)->trim();
124
+            }
114 125
         }
115 126
 
116 127
         return $return;
Please login to merge, or discard this patch.
src/Builder.php 3 patches
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@  discard block
 block discarded – undo
27 27
 		$this->cache = new Cache(new \ArrayObject());
28 28
 		$this->filePath = new FilePath();
29 29
 		$modules = is_array($modules) ? $modules : $this->defaultModules;
30
-		foreach ($modules as $module) $this->loadModule(new $module);
30
+		foreach ($modules as $module) {
31
+			$this->loadModule(new $module);
32
+		}
31 33
 	}
32 34
 
33 35
 	//Allow setting the time used by Transphporm for caching. This is for testing purposes
@@ -80,7 +82,9 @@  discard block
 block discarded – undo
80 82
 		$valueParser = new Parser\Value($functionSet);
81 83
 		$this->config = new Config($functionSet, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($functionSet, $template->getPrefix(), md5($this->tss)), $this->filePath, $headers);
82 84
 
83
-		foreach ($this->modules as $module) $module->load($this->config);
85
+		foreach ($this->modules as $module) {
86
+			$module->load($this->config);
87
+		}
84 88
 		return $template;
85 89
 	}
86 90
 
@@ -94,7 +98,9 @@  discard block
 block discarded – undo
94 98
 	//Load a template, firstly check if it's a file or a valid string
95 99
 	private function loadTemplate() {
96 100
         $result = ['cache' => $this->template, 'headers' => []];
97
-		if (strpos($this->template, "\n") === false && is_file($this->template)) $result = $this->loadTemplateFromFile($this->template);
101
+		if (strpos($this->template, "\n") === false && is_file($this->template)) {
102
+			$result = $this->loadTemplateFromFile($this->template);
103
+		}
98 104
 		return $result;
99 105
 	}
100 106
 
@@ -113,6 +119,8 @@  discard block
 block discarded – undo
113 119
 
114 120
 	public function __destruct() {
115 121
 		//Required hack as DomXPath can only register static functions clear the statically stored instance to avoid memory leaks
116
-		if (isset($this->config)) $this->config->getCssToXpath()->cleanup();
122
+		if (isset($this->config)) {
123
+			$this->config->getCssToXpath()->cleanup();
124
+		}
117 125
 	}
118 126
 }
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	}
43 43
 
44 44
 	public function setLocale($locale) {
45
-        $format = new \Transphporm\Module\Format($locale);
46
-        $this->modules[get_class($format)] = $format;
47
-    }
45
+		$format = new \Transphporm\Module\Format($locale);
46
+		$this->modules[get_class($format)] = $format;
47
+	}
48 48
 
49 49
 	public function addPath($dir) {
50 50
 		$this->filePath->addPath($dir);
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
 
101 101
 	//Load a template, firstly check if it's a file or a valid string
102 102
 	private function loadTemplate() {
103
-        $result = ['cache' => $this->template, 'headers' => []];
103
+		$result = ['cache' => $this->template, 'headers' => []];
104 104
 		if (strpos($this->template, "\n") === false && is_file($this->template)) $result = $this->loadTemplateFromFile($this->template);
105 105
 		return $result;
106 106
 	}
107 107
 
108
-    private function loadTemplateFromFile($file) {
109
-        $xml = $this->cache->load($this->cacheKey . $file, filemtime($file));
110
-        return $xml ? $xml : ['cache' => file_get_contents($file) ?: "", 'headers' => []];
111
-    }
108
+	private function loadTemplateFromFile($file) {
109
+		$xml = $this->cache->load($this->cacheKey . $file, filemtime($file));
110
+		return $xml ? $xml : ['cache' => file_get_contents($file) ?: "", 'headers' => []];
111
+	}
112 112
 
113 113
 	public function setCache(\ArrayAccess $cache) {
114 114
 		$this->cache = new Cache($cache);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			   'headers' => array_merge($result['headers'], $headers),
73 73
 			   'body' => $this->doPostProcessing($template)->output($document)
74 74
 			];
75
-			$this->cache->write($tssCache->getCacheKey($data) . $this->template, $result);
75
+			$this->cache->write($tssCache->getCacheKey($data).$this->template, $result);
76 76
 		}
77 77
 		unset($result['cache'], $result['renderTime']);
78 78
 		return (object) $result;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		$elementData = new \Transphporm\Hook\ElementData(new \SplObjectStorage(), $data);
83 83
 		$functionSet = new FunctionSet($elementData);
84 84
 		//To be a valid XML document it must have a root element, automatically wrap it in <template> to ensure it does
85
-		$template = new Template($this->isValidDoc($body) ? str_ireplace('<!doctype', '<!DOCTYPE', $body) : '<template>' . $body . '</template>' );
85
+		$template = new Template($this->isValidDoc($body) ? str_ireplace('<!doctype', '<!DOCTYPE', $body) : '<template>'.$body.'</template>');
86 86
 
87 87
 		$valueParser = new Parser\Value($functionSet);
88 88
 		$this->config = new Config($functionSet, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($functionSet, $template->getPrefix(), md5($this->tss)), $this->filePath, $headers);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 
108 108
     private function loadTemplateFromFile($file) {
109
-        $xml = $this->cache->load($this->cacheKey . $file, filemtime($file));
109
+        $xml = $this->cache->load($this->cacheKey.$file, filemtime($file));
110 110
         return $xml ? $xml : ['cache' => file_get_contents($file) ?: "", 'headers' => []];
111 111
     }
112 112
 
Please login to merge, or discard this patch.
src/Property/Content.php 1 patch
Braces   +19 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
17
-		if (!$this->shouldRun($element)) return false;
17
+		if (!$this->shouldRun($element)) {
18
+			return false;
19
+		}
18 20
 
19 21
 		$values = $this->formatter->format($values, $rules);
20 22
 
@@ -25,14 +27,17 @@  discard block
 block discarded – undo
25 27
 			if ($this->getContentMode($rules) === 'replace') {
26 28
 				$contentReplace = new ContentReplace($this);
27 29
 				$contentReplace->replaceContent($element, $values);
30
+			} else {
31
+				$this->appendContent($element, $values);
28 32
 			}
29
-			else $this->appendContent($element, $values);
30 33
 		}
31 34
 	}
32 35
 
33 36
 	private function shouldRun($element) {
34 37
 		do {
35
-			if ($element->getAttribute('transphporm') == 'includedtemplate') return false;
38
+			if ($element->getAttribute('transphporm') == 'includedtemplate') {
39
+				return false;
40
+			}
36 41
 		}
37 42
 		while (($element = $element->parentNode) instanceof \DomElement);
38 43
 		return true;
@@ -59,9 +64,10 @@  discard block
 block discarded – undo
59 64
 	public function getNode($node, $document) {
60 65
 		foreach ($node as $n) {
61 66
 			if (is_array($n)) {
62
-				foreach ($this->getNode($n, $document) as $new) yield $new;
63
-			}
64
-			else {
67
+				foreach ($this->getNode($n, $document) as $new) {
68
+					yield $new;
69
+				}
70
+			} else {
65 71
 				yield $this->convertNode($n, $document);
66 72
 			}
67 73
 		}
@@ -70,9 +76,10 @@  discard block
 block discarded – undo
70 76
 	private function convertNode($node, $document) {
71 77
 		if ($node instanceof \DomElement || $node instanceof \DOMComment) {
72 78
 			$new = $document->importNode($node, true);
73
-		}
74
-		else {
75
-			if ($node instanceof \DomText) $node = $node->nodeValue;
79
+		} else {
80
+			if ($node instanceof \DomText) {
81
+				$node = $node->nodeValue;
82
+			}
76 83
 			$new = $document->createElement('text');
77 84
 
78 85
 			$new->appendChild($document->createTextNode($node));
@@ -89,6 +96,8 @@  discard block
 block discarded – undo
89 96
 	}
90 97
 
91 98
 	private function removeAllChildren($element) {
92
-		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
99
+		while ($element->hasChildNodes()) {
100
+			$element->removeChild($element->firstChild);
101
+		}
93 102
 	}
94 103
 }
95 104
\ No newline at end of file
Please login to merge, or discard this patch.
src/Property/ContentReplace.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	public function replaceContent($element, $content) {
16
-		if ($element->getAttribute('transphporm') == 'added') return;
16
+		if ($element->getAttribute('transphporm') == 'added') {
17
+			return;
18
+		}
17 19
 		//If this rule was cached, the elements that were added last time need to be removed prior to running the rule again.
18 20
 		if ($element->getAttribute('transphporm')) {
19 21
 			$this->replaceCachedContent($element);
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 
28 30
 	private function insertNodes($element, $content) {
29 31
 		foreach ($this->content->getNode($content, $element->ownerDocument) as $node) {
30
-			if ($node instanceof \DomElement && !$node->getAttribute('transphporm'))  $node->setAttribute('transphporm', 'added');
32
+			if ($node instanceof \DomElement && !$node->getAttribute('transphporm')) {
33
+				$node->setAttribute('transphporm', 'added');
34
+			}
31 35
 			$element->parentNode->insertBefore($node, $element);
32 36
 		}
33 37
 	}
Please login to merge, or discard this patch.
src/SheetLoader/SheetLoader.php 4 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -42,6 +42,9 @@  discard block
 block discarded – undo
42 42
 	}
43 43
 
44 44
 
45
+	/**
46
+	 * @param \Transphporm\Template $template
47
+	 */
45 48
 	public function processRules($template, \Transphporm\Config $config) {
46 49
 		$rules = $this->getRules($config->getCssToXpath(), $config->getValueParser());
47 50
 
@@ -57,11 +60,20 @@  discard block
 block discarded – undo
57 60
 	}
58 61
 
59 62
 	//Load the TSS
63
+
64
+	/**
65
+	 * @param \Transphporm\Parser\CssToXpath $cssToXpath
66
+	 * @param \Transphporm\Parser\Value $valueParser
67
+	 */
60 68
 	public function getRules($cssToXpath, $valueParser, $indexStart = 0) {
61 69
 		return $this->tss->getRules($cssToXpath, $valueParser, $this, $indexStart);
62 70
 	}
63 71
 
64 72
 	//Process a TSS rule e.g. `ul li {content: "foo"; format: bar}
73
+
74
+	/**
75
+	 * @param \Transphporm\Config $config
76
+	 */
65 77
 	private function executeTssRule($rule, $template, $config) {
66 78
 		$rule->touch();
67 79
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,6 +84,6 @@
 block discarded – undo
84 84
 
85 85
 
86 86
 	private function sortPseudo($a, $b) {
87
-		return count($a->pseudo) > count($b->pseudo)  ? 1 : -1;
87
+		return count($a->pseudo) > count($b->pseudo) ? 1 : -1;
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
 			if ($token['type'] == \Transphporm\Parser\Tokenizer::NAME && $token['value'] == 'data') {
40 40
 				$tokens->next();
41 41
 				$newTokens = array_merge($newTokens, iterator_to_array($tokens->current()['value']));
42
+			} else {
43
+				$newTokens[] = $token;
42 44
 			}
43
-			else $newTokens[] = $token;
44 45
 		}
45 46
 
46 47
 		$this->tss->setCacheKey(new \Transphporm\Parser\Tokens($newTokens));
@@ -58,7 +59,9 @@  discard block
 block discarded – undo
58 59
 		usort($rules, [$this, 'sortRules']);
59 60
 
60 61
 		foreach ($rules as $rule) {
61
-			if ($rule->shouldRun($this->time)) $this->executeTssRule($rule, $template, $config);
62
+			if ($rule->shouldRun($this->time)) {
63
+				$this->executeTssRule($rule, $template, $config);
64
+			}
62 65
 		}
63 66
 
64 67
 		//if (is_file($this->tss)) $this->write($this->tss, $rules, $this->import);
@@ -83,10 +86,15 @@  discard block
 block discarded – undo
83 86
 
84 87
 	private function sortRules($a, $b) {
85 88
 		//If they have the same depth, compare on index
86
-		if ($a->query === $b->query) return $this->sortPseudo($a, $b);
89
+		if ($a->query === $b->query) {
90
+			return $this->sortPseudo($a, $b);
91
+		}
87 92
 
88
-		if ($a->depth === $b->depth) $property = 'index';
89
-		else $property = 'depth';
93
+		if ($a->depth === $b->depth) {
94
+			$property = 'index';
95
+		} else {
96
+			$property = 'depth';
97
+		}
90 98
 
91 99
 		return ($a->$property < $b->$property) ? -1 : 1;
92 100
 	}
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@
 block discarded – undo
7 7
 namespace Transphporm\SheetLoader;
8 8
 //Separates out TSS file loading/caching from parsing
9 9
 class SheetLoader {
10
-    private $tss;
11
-    private $filePath;
12
-    private $time;
13
-    private $import = [];
14
-
15
-    public function __construct(\Transphporm\Cache $cache, \Transphporm\FilePath $filePath, TSSRules $tss, $time) {
16
-    	$this->cache = $cache;
17
-        $this->filePath = $filePath;
18
-        $this->tss = $tss;
19
-        $this->time = isset($time) ? $time : time();
20
-    }
10
+	private $tss;
11
+	private $filePath;
12
+	private $time;
13
+	private $import = [];
14
+
15
+	public function __construct(\Transphporm\Cache $cache, \Transphporm\FilePath $filePath, TSSRules $tss, $time) {
16
+		$this->cache = $cache;
17
+		$this->filePath = $filePath;
18
+		$this->tss = $tss;
19
+		$this->time = isset($time) ? $time : time();
20
+	}
21 21
 
22 22
 	//Allows controlling whether any updates are required to the template
23 23
 	//e.g. return false
Please login to merge, or discard this patch.
src/Parser/Tokenizer/Brackets.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 
11 11
 class Brackets implements \Transphporm\Parser\Tokenizable {
12 12
 
13
-	private $types =  [
13
+	private $types = [
14 14
 			Tokenizer::OPEN_BRACKET => ['(', ')'],
15 15
 			Tokenizer::OPEN_BRACE => ['{', '}'],
16 16
 			Tokenizer::OPEN_SQUARE_BRACKET => ['[', ']']
Please login to merge, or discard this patch.
src/SheetLoader/TSSFile.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 		$this->fileName = $fileName;
18 18
 		$this->filePath = $filePath;
19 19
 		$this->cache = $cache;
20
-	    $this->time = isset($time) ? $time : time();
21
-	    $this->cacheName = $this->fileName;
20
+		$this->time = isset($time) ? $time : time();
21
+		$this->cacheName = $this->fileName;
22 22
 	}
23 23
 
24 24
 	private function getRulesFromCache($file) {
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 	}
78 78
 
79 79
 	//write the sheet to cache
80
-    public function write($rules, $imports = []) {
80
+	public function write($rules, $imports = []) {
81 81
 		$existing = $this->cache->load($this->fileName, filemtime($this->fileName));
82 82
 		if (isset($existing['import']) && empty($imports)) $imports = $existing['import'];
83 83
 		$this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]);
84 84
 
85 85
 		return $rules;
86
-    }
86
+	}
87 87
 
88
-    //Gets the minimum update-frequency for a sheet's rules
88
+	//Gets the minimum update-frequency for a sheet's rules
89 89
 	private function getMinUpdateFreq($rules) {
90 90
 		$min = \PHP_INT_MAX;
91 91
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 		if ($this->cacheKey) {
62 62
 			$parser = new \Transphporm\Parser\Value($data);
63 63
 			$cacheKey = $parser->parseTokens($this->cacheKey)[0];
64
-			$this->cacheName = $cacheKey . $this->fileName;
64
+			$this->cacheName = $cacheKey.$this->fileName;
65 65
 			return $cacheKey;
66 66
 		}
67 67
 		else return $this->fileName;
Please login to merge, or discard this patch.
Braces   +22 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,9 @@  discard block
 block discarded – undo
32 32
 		if ($rules) {
33 33
 			foreach ($rules['import'] as $file) {
34 34
 				//Check that the import file hasn't been changed since the cache was written
35
-				if (filemtime($file) > $rules['ctime']) return false;
35
+				if (filemtime($file) > $rules['ctime']) {
36
+					return false;
37
+				}
36 38
 			}
37 39
 		}
38 40
 
@@ -48,10 +50,14 @@  discard block
 block discarded – undo
48 50
 
49 51
 		$rules = $this->getRulesFromCache($this->fileName);
50 52
 		//Nothing was cached or the TSS file has changed, update is required
51
-		if (empty($rules)) return true;
53
+		if (empty($rules)) {
54
+			return true;
55
+		}
52 56
 
53 57
 		//Find the sheet's minimum update-frequency, if it hasn't passed then no updates are required
54
-		if ($rules['ctime']+$rules['minFreq'] <= $this->time) return true;
58
+		if ($rules['ctime']+$rules['minFreq'] <= $this->time) {
59
+			return true;
60
+		}
55 61
 
56 62
 		return false;
57 63
 	}
@@ -63,15 +69,19 @@  discard block
 block discarded – undo
63 69
 			$cacheKey = $parser->parseTokens($this->cacheKey)[0];
64 70
 			$this->cacheName = $cacheKey . $this->fileName;
65 71
 			return $cacheKey;
72
+		} else {
73
+			return $this->fileName;
66 74
 		}
67
-		else return $this->fileName;
68 75
 	}
69 76
 
70 77
 	public function getRules($cssToXpath, $valueParser, $sheetLoader, $indexStart) {
71 78
 		$rules = $this->getRulesFromCache($this->fileName);
72 79
 		$this->filePath->addPath(dirname(realpath($this->fileName)));
73
-		if (empty($rules)) $tss = file_get_contents($this->fileName);
74
-		else return $rules['rules'];
80
+		if (empty($rules)) {
81
+			$tss = file_get_contents($this->fileName);
82
+		} else {
83
+			return $rules['rules'];
84
+		}
75 85
 
76 86
 		return $tss == null ? [] : (new \Transphporm\Parser\Sheet($tss, $cssToXpath, $valueParser, $this->filePath, $sheetLoader))->parse($indexStart);
77 87
 	}
@@ -79,7 +89,9 @@  discard block
 block discarded – undo
79 89
 	//write the sheet to cache
80 90
     public function write($rules, $imports = []) {
81 91
 		$existing = $this->cache->load($this->fileName, filemtime($this->fileName));
82
-		if (isset($existing['import']) && empty($imports)) $imports = $existing['import'];
92
+		if (isset($existing['import']) && empty($imports)) {
93
+			$imports = $existing['import'];
94
+		}
83 95
 		$this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]);
84 96
 
85 97
 		return $rules;
@@ -91,7 +103,9 @@  discard block
 block discarded – undo
91 103
 
92 104
 		foreach ($rules as $rule) {
93 105
 			$ruleFreq = $rule->getUpdateFrequency();
94
-			if ($ruleFreq < $min) $min = $ruleFreq;
106
+			if ($ruleFreq < $min) {
107
+				$min = $ruleFreq;
108
+			}
95 109
 		}
96 110
 
97 111
 		return $min;
Please login to merge, or discard this patch.
src/TSSFunction/Constant.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 	public function run(array $args, \DomElement $element) {
11 11
 		$const_name = strtoupper(trim($args[0]));
12 12
 		if (!defined($const_name)) {
13
-			throw new \Exception($const_name . ' is not a defined constant');
13
+			throw new \Exception($const_name.' is not a defined constant');
14 14
 		}
15 15
 		return constant($const_name);
16 16
 	}
Please login to merge, or discard this patch.