Completed
Push — master ( f8660b...c42a51 )
by Tom
01:54
created
src/SheetLoader.php 1 patch
Braces   +37 added lines, -13 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
 		return $rules;
@@ -40,12 +42,18 @@  discard block
 block discarded – undo
40 42
 	//   2. If the data hasn't changed since the last run
41 43
 	//If this function returns false, the rendered template is sent straight from the cache skipping 99% of transphporm's code
42 44
 	public function updateRequired($data) {
43
-		if (!is_file($this->tss)) return true;
45
+		if (!is_file($this->tss)) {
46
+			return true;
47
+		}
44 48
 		$rules = $this->getRulesFromCache($this->tss);
45 49
 		//Nothing was cached or the TSS file has changed, update is required
46
-		if (empty($rules)) return true;
50
+		if (empty($rules)) {
51
+			return true;
52
+		}
47 53
 		//Find the sheet's minimum update-frequency, if it hasn't passed then no updates are required
48
-		if ($rules['ctime']+$rules['minFreq'] <= $this->time) return true;
54
+		if ($rules['ctime']+$rules['minFreq'] <= $this->time) {
55
+			return true;
56
+		}
49 57
 
50 58
 		return false;
51 59
 	}
@@ -56,7 +64,9 @@  discard block
 block discarded – undo
56 64
 
57 65
 		foreach ($rules as $rule) {
58 66
 			$ruleFreq = $rule->getUpdateFrequency();
59
-			if ($ruleFreq < $min) $min = $ruleFreq;
67
+			if ($ruleFreq < $min) {
68
+				$min = $ruleFreq;
69
+			}
60 70
 		}
61 71
 
62 72
 		return $min;
@@ -75,7 +85,9 @@  discard block
 block discarded – undo
75 85
 		if (is_file($file)) {
76 86
 			$key = $this->getCacheKey($file);
77 87
 			$existing = $this->cache->load($key, filemtime($file));
78
-			if (isset($existing['import']) && empty($imports)) $imports = $existing['import'];
88
+			if (isset($existing['import']) && empty($imports)) {
89
+				$imports = $existing['import'];
90
+			}
79 91
 			$this->cache->write($file, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => time()]);
80 92
 		}
81 93
 		return $rules;
@@ -87,10 +99,14 @@  discard block
 block discarded – undo
87 99
 		usort($rules, [$this, 'sortRules']);
88 100
 
89 101
 		foreach ($rules as $rule) {
90
-			if ($rule->shouldRun($this->time)) $this->executeTssRule($rule, $template, $config);
102
+			if ($rule->shouldRun($this->time)) {
103
+				$this->executeTssRule($rule, $template, $config);
104
+			}
91 105
 		}
92 106
 
93
-		if (is_file($this->tss)) $this->write($this->tss, $rules, $this->import);
107
+		if (is_file($this->tss)) {
108
+			$this->write($this->tss, $rules, $this->import);
109
+		}
94 110
 	}
95 111
 
96 112
 	//Load the TSS
@@ -99,8 +115,11 @@  discard block
 block discarded – undo
99 115
     		//$rules = $this->cache->load($tss);
100 116
     		$rules = $this->getRulesFromCache($tss)['rules'];
101 117
 			$this->filePath->addPath(dirname(realpath($tss)));
102
-			if (empty($rules)) $tss = file_get_contents($tss);
103
-			else return $rules;
118
+			if (empty($rules)) {
119
+				$tss = file_get_contents($tss);
120
+			} else {
121
+				return $rules;
122
+			}
104 123
     	}
105 124
 		return $tss == null ? [] : (new Parser\Sheet($tss, $cssToXpath, $valueParser, $this->filePath, $this))->parse();
106 125
 	}
@@ -118,10 +137,15 @@  discard block
 block discarded – undo
118 137
 
119 138
 	private function sortRules($a, $b) {
120 139
 		//If they have the same depth, compare on index
121
-		if ($a->query === $b->query) return $this->sortPseudo($a, $b);
140
+		if ($a->query === $b->query) {
141
+			return $this->sortPseudo($a, $b);
142
+		}
122 143
 
123
-		if ($a->depth === $b->depth) $property = 'index';
124
-		else $property = 'depth';
144
+		if ($a->depth === $b->depth) {
145
+			$property = 'index';
146
+		} else {
147
+			$property = 'depth';
148
+		}
125 149
 
126 150
 		return ($a->$property < $b->$property) ? -1 : 1;
127 151
 	}
Please login to merge, or discard this patch.