Completed
Push — master ( f4d4c4...598d1e )
by Tom
02:08
created
src/SheetLoader/TSSFile.php 1 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
 			$x= $parser->parseTokens($this->cacheKey)[0];
61 67
 			$this->cacheName = $x . $this->tss;
62 68
 			return $x;
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
 	}
@@ -77,7 +87,9 @@  discard block
 block discarded – undo
77 87
     public function write($rules, $imports = []) {
78 88
 
79 89
 		$existing = $this->cache->load($this->fileName, filemtime($this->fileName));
80
-		if (isset($existing['import']) && empty($imports)) $imports = $existing['import'];
90
+		if (isset($existing['import']) && empty($imports)) {
91
+			$imports = $existing['import'];
92
+		}
81 93
 		$this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]);
82 94
 
83 95
 		return $rules;
@@ -89,7 +101,9 @@  discard block
 block discarded – undo
89 101
 
90 102
 		foreach ($rules as $rule) {
91 103
 			$ruleFreq = $rule->getUpdateFrequency();
92
-			if ($ruleFreq < $min) $min = $ruleFreq;
104
+			if ($ruleFreq < $min) {
105
+				$min = $ruleFreq;
106
+			}
93 107
 		}
94 108
 
95 109
 		return $min;
Please login to merge, or discard this patch.
src/SheetLoader/SheetLoader.php 1 patch
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,7 +49,9 @@  discard block
 block discarded – undo
49 49
 		usort($rules, [$this, 'sortRules']);
50 50
 
51 51
 		foreach ($rules as $rule) {
52
-			if ($rule->shouldRun($this->time)) $this->executeTssRule($rule, $template, $config);
52
+			if ($rule->shouldRun($this->time)) {
53
+				$this->executeTssRule($rule, $template, $config);
54
+			}
53 55
 		}
54 56
 
55 57
 		//if (is_file($this->tss)) $this->write($this->tss, $rules, $this->import);
@@ -74,10 +76,15 @@  discard block
 block discarded – undo
74 76
 
75 77
 	private function sortRules($a, $b) {
76 78
 		//If they have the same depth, compare on index
77
-		if ($a->query === $b->query) return $this->sortPseudo($a, $b);
79
+		if ($a->query === $b->query) {
80
+			return $this->sortPseudo($a, $b);
81
+		}
78 82
 
79
-		if ($a->depth === $b->depth) $property = 'index';
80
-		else $property = 'depth';
83
+		if ($a->depth === $b->depth) {
84
+			$property = 'index';
85
+		} else {
86
+			$property = 'depth';
87
+		}
81 88
 
82 89
 		return ($a->$property < $b->$property) ? -1 : 1;
83 90
 	}
Please login to merge, or discard this patch.