Completed
Push — master ( 02c8a1...58faf5 )
by Tom
02:14
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/Builder.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -85,6 +85,10 @@
 block discarded – undo
85 85
 	}
86 86
 
87 87
 	//Add a postprocessing hook. This cleans up anything transphporm has added to the markup which needs to be removed
88
+
89
+	/**
90
+	 * @param Template $template
91
+	 */
88 92
 	private function doPostProcessing($template) {
89 93
 		$template->addHook('//*[@transphporm]', new Hook\PostProcess());
90 94
 		return $template;
Please login to merge, or discard this patch.
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);
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
 
98 98
 	//Load a template, firstly check if it's a file or a valid string
99 99
 	private function loadTemplate() {
100
-        $result = ['cache' => $this->template, 'headers' => []];
100
+		$result = ['cache' => $this->template, 'headers' => []];
101 101
 		if (strpos($this->template, "\n") === false && is_file($this->template)) $result = $this->loadTemplateFromFile($this->template);
102 102
 		return $result;
103 103
 	}
104 104
 
105
-    private function loadTemplateFromFile($file) {
106
-        $xml = $this->cache->load($this->cacheKey . $this->template, filemtime($this->template));
107
-        return $xml ? $xml : ['cache' => file_get_contents($this->template) ?: "", 'headers' => []];
108
-    }
105
+	private function loadTemplateFromFile($file) {
106
+		$xml = $this->cache->load($this->cacheKey . $this->template, filemtime($this->template));
107
+		return $xml ? $xml : ['cache' => file_get_contents($this->template) ?: "", 'headers' => []];
108
+	}
109 109
 
110 110
 	public function setCache(\ArrayAccess $cache) {
111 111
 		$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 . $this->template, filemtime($this->template));
109
+        $xml = $this->cache->load($this->cacheKey.$this->template, filemtime($this->template));
110 110
         return $xml ? $xml : ['cache' => file_get_contents($this->template) ?: "", '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.
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 = $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 = $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.
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.
src/SheetLoader/TSSFile.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -12,6 +12,10 @@
 block discarded – undo
12 12
 	private $cache;
13 13
 	private $time;
14 14
 
15
+	/**
16
+	 * @param string $fileName
17
+	 * @param \Transphporm\Cache $cache
18
+	 */
15 19
 	public function __construct($fileName, \Transphporm\FilePath $filePath, $cache, $time) {
16 20
 		$this->fileName = $fileName;
17 21
 		$this->filePath = $filePath;
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 		$this->fileName = $fileName;
17 17
 		$this->filePath = $filePath;
18 18
 		$this->cache = $cache;
19
-	    $this->time = $time ?? time();
20
-	    $this->cacheName = $this->fileName;
19
+		$this->time = $time ?? time();
20
+		$this->cacheName = $this->fileName;
21 21
 	}
22 22
 
23 23
 	private function getRulesFromCache($file) {
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	//write the sheet to cache
77
-    public function write($rules, $imports = []) {
77
+	public function write($rules, $imports = []) {
78 78
 
79 79
 		$existing = $this->cache->load($this->fileName, filemtime($this->fileName));
80 80
 		if (isset($existing['import']) && empty($imports)) $imports = $existing['import'];
81 81
 		$this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]);
82 82
 
83 83
 		return $rules;
84
-    }
84
+	}
85 85
 
86
-    //Gets the minimum update-frequency for a sheet's rules
86
+	//Gets the minimum update-frequency for a sheet's rules
87 87
 	private function getMinUpdateFreq($rules) {
88 88
 		$min = \PHP_INT_MAX;
89 89
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	}
42 42
 
43 43
 	public function updateRequired($data) {
44
-		$this->cacheName = $this->getCacheKey($data) . $this->fileName;
44
+		$this->cacheName = $this->getCacheKey($data).$this->fileName;
45 45
 
46 46
 		$rules = $this->getRulesFromCache($this->fileName, $data);
47 47
 		//Nothing was cached or the TSS file has changed, update is required
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		if ($this->cacheKey) {
59 59
 			$parser = new \Transphporm\Parser\Value($data);
60 60
 			$cacheKey = $parser->parseTokens($this->cacheKey)[0];
61
-			$this->cacheName = $cacheKey . $this->fileName;
61
+			$this->cacheName = $cacheKey.$this->fileName;
62 62
 			return $cacheKey;
63 63
 		}
64 64
 		else return '';
Please login to merge, or discard this patch.
Braces   +22 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if ($rules) {
30 30
 			foreach ($rules['import'] as $file) {
31 31
 				//Check that the import file hasn't been changed since the cache was written
32
-				if (filemtime($file) > $rules['ctime']) return false;
32
+				if (filemtime($file) > $rules['ctime']) {
33
+					return false;
34
+				}
33 35
 			}
34 36
 		}
35 37
 
@@ -45,10 +47,14 @@  discard block
 block discarded – undo
45 47
 
46 48
 		$rules = $this->getRulesFromCache($this->fileName, $data);
47 49
 		//Nothing was cached or the TSS file has changed, update is required
48
-		if (empty($rules)) return true;
50
+		if (empty($rules)) {
51
+			return true;
52
+		}
49 53
 
50 54
 		//Find the sheet's minimum update-frequency, if it hasn't passed then no updates are required
51
-		if ($rules['ctime']+$rules['minFreq'] <= $this->time) return true;
55
+		if ($rules['ctime']+$rules['minFreq'] <= $this->time) {
56
+			return true;
57
+		}
52 58
 
53 59
 		return false;
54 60
 	}
@@ -60,15 +66,19 @@  discard block
 block discarded – undo
60 66
 			$cacheKey = $parser->parseTokens($this->cacheKey)[0];
61 67
 			$this->cacheName = $cacheKey . $this->fileName;
62 68
 			return $cacheKey;
69
+		} else {
70
+			return '';
63 71
 		}
64
-		else return '';
65 72
 	}
66 73
 
67 74
 	public function getRules($cssToXpath, $valueParser, $sheetLoader, $indexStart) {
68 75
 		$rules = $this->getRulesFromCache($this->fileName)['rules'];
69 76
 		$this->filePath->addPath(dirname(realpath($this->fileName)));
70
-		if (empty($rules)) $tss = file_get_contents($this->fileName);
71
-		else return $rules;
77
+		if (empty($rules)) {
78
+			$tss = file_get_contents($this->fileName);
79
+		} else {
80
+			return $rules;
81
+		}
72 82
 
73 83
 		return $tss == null ? [] : (new \Transphporm\Parser\Sheet($tss, $cssToXpath, $valueParser, $this->filePath, $sheetLoader))->parse($indexStart);
74 84
 	}
@@ -76,7 +86,9 @@  discard block
 block discarded – undo
76 86
 	//write the sheet to cache
77 87
     public function write($rules, $imports = []) {
78 88
 		$existing = $this->cache->load($this->fileName, filemtime($this->fileName));
79
-		if (isset($existing['import']) && empty($imports)) $imports = $existing['import'];
89
+		if (isset($existing['import']) && empty($imports)) {
90
+			$imports = $existing['import'];
91
+		}
80 92
 		$this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]);
81 93
 
82 94
 		return $rules;
@@ -88,7 +100,9 @@  discard block
 block discarded – undo
88 100
 
89 101
 		foreach ($rules as $rule) {
90 102
 			$ruleFreq = $rule->getUpdateFrequency();
91
-			if ($ruleFreq < $min) $min = $ruleFreq;
103
+			if ($ruleFreq < $min) {
104
+				$min = $ruleFreq;
105
+			}
92 106
 		}
93 107
 
94 108
 		return $min;
Please login to merge, or discard this patch.
src/SheetCache.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@
 block discarded – undo
44 44
 
45 45
 
46 46
 	//write the sheet to cache
47
-    public function write($file, $rules, $imports = []) {
47
+	public function write($file, $rules, $imports = []) {
48 48
 		if (is_file($file)) {
49 49
 			$existing = $this->cache->load($file, filemtime($file));
50 50
 			if (isset($existing['import'])) $imports = $existing['import'];
51 51
 			$this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]);
52 52
 		}
53 53
 		return $rules;
54
-    }
54
+	}
55 55
 
56
-    public function setKey($key) {
57
-    	$this->cacheKey = $key;
58
-    }
56
+	public function setKey($key) {
57
+		$this->cacheKey = $key;
58
+	}
59 59
 
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 		if ($this->cacheKey) {
37 37
 			$parser = new Parser\Value($data);
38 38
 			$parsedKey = $parser->parseTokens($this->cacheKey)[0];
39
-			$this->cacheName = $parsedKey . $this->tss;
39
+			$this->cacheName = $parsedKey.$this->tss;
40 40
 			return $parsedKey;
41 41
 		}
42 42
 		else return '';
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 		if ($rules) {
25 25
 			foreach ($rules['import'] as $file) {
26 26
 				//Check that the import file hasn't been changed since the cache was written
27
-				if (filemtime($file) > $rules['ctime']) return false;
27
+				if (filemtime($file) > $rules['ctime']) {
28
+					return false;
29
+				}
28 30
 			}
29 31
 		}
30 32
 		return $rules;
@@ -32,14 +34,17 @@  discard block
 block discarded – undo
32 34
 
33 35
 	public function getCacheKey($tss, $data) {
34 36
 		//Read the rules so that $this->cacheKey is set
35
-		if (is_file($tss)) $this->getRulesFromCache($tss);
37
+		if (is_file($tss)) {
38
+			$this->getRulesFromCache($tss);
39
+		}
36 40
 		if ($this->cacheKey) {
37 41
 			$parser = new Parser\Value($data);
38 42
 			$parsedKey = $parser->parseTokens($this->cacheKey)[0];
39 43
 			$this->cacheName = $parsedKey . $this->tss;
40 44
 			return $parsedKey;
45
+		} else {
46
+			return '';
41 47
 		}
42
-		else return '';
43 48
 	}
44 49
 
45 50
 
@@ -47,7 +52,9 @@  discard block
 block discarded – undo
47 52
     public function write($file, $rules, $imports = []) {
48 53
 		if (is_file($file)) {
49 54
 			$existing = $this->cache->load($file, filemtime($file));
50
-			if (isset($existing['import'])) $imports = $existing['import'];
55
+			if (isset($existing['import'])) {
56
+				$imports = $existing['import'];
57
+			}
51 58
 			$this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]);
52 59
 		}
53 60
 		return $rules;
Please login to merge, or discard this patch.