Completed
Push — master ( c766ad...49caad )
by Tom
05:37
created
src/Parser/Sheet.php 1 patch
Braces   +21 added lines, -9 removed lines patch added patch discarded remove patch
@@ -33,9 +33,13 @@  discard block
 block discarded – undo
33 33
 			$rules = $this->writeRule($rules, $newRules);
34 34
 		}
35 35
 		//there may be processing instructions at the end
36
-		if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) $rules = array_merge($rules, $processing['rules']);
36
+		if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) {
37
+			$rules = array_merge($rules, $processing['rules']);
38
+		}
37 39
 		usort($rules, [$this, 'sortRules']);
38
-		if (empty($rules) && !empty($this->tss)) throw new \Exception("No TSS rules parsed");
40
+		if (empty($rules) && !empty($this->tss)) {
41
+			throw new \Exception("No TSS rules parsed");
42
+		}
39 43
 		return $rules;
40 44
 	}
41 45
 
@@ -69,8 +73,7 @@  discard block
 block discarded – undo
69 73
 				$pos = strpos($tss, ';', $spacePos);
70 74
 				$args = substr($tss, $spacePos+1, $pos-$spacePos-1);
71 75
 				$rules = array_merge($rules, $this->$funcName($args, $indexStart));
72
-			}
73
-			else {
76
+			} else {
74 77
 				break;
75 78
 			}
76 79
 		}
@@ -79,15 +82,20 @@  discard block
 block discarded – undo
79 82
 	}
80 83
 
81 84
 	private function import($args, $indexStart) {
82
-		if (is_file(trim($args,'\'" '))) $fileName = trim($args,'\'" ');
83
-		else $fileName = $this->valueParser->parse($args)[0];
85
+		if (is_file(trim($args,'\'" '))) {
86
+			$fileName = trim($args,'\'" ');
87
+		} else {
88
+			$fileName = $this->valueParser->parse($args)[0];
89
+		}
84 90
 		$sheet = new Sheet(file_get_contents($this->baseDir . $fileName), $this->baseDir, $this->xPath, $this->valueParser);
85 91
 		return $sheet->parse(0, [], $indexStart);
86 92
 	}
87 93
 
88 94
 	private function sortRules($a, $b) {
89 95
 		//If they have the same depth, compare on index
90
-		if ($a->depth === $b->depth) return $a->index < $b->index ? -1 : 1;
96
+		if ($a->depth === $b->depth) {
97
+			return $a->index < $b->index ? -1 : 1;
98
+		}
91 99
 
92 100
 		return ($a->depth < $b->depth) ? -1 : 1;
93 101
 	}
@@ -96,7 +104,9 @@  discard block
 block discarded – undo
96 104
 		$pos = 0;
97 105
 		while (($pos = strpos($str, $open, $pos)) !== false) {
98 106
 			$end = strpos($str, $close, $pos);
99
-			if ($end === false) break;
107
+			if ($end === false) {
108
+				break;
109
+			}
100 110
 			$str = substr_replace($str, '', $pos, $end-$pos+2);
101 111
 		}
102 112
 
@@ -109,7 +119,9 @@  discard block
 block discarded – undo
109 119
 		$return = [];
110 120
 
111 121
 		foreach ($rules as $rule) {
112
-			if (trim($rule) === '') continue;
122
+			if (trim($rule) === '') {
123
+				continue;
124
+			}
113 125
 			$parts = explode(':', $rule, 2);
114 126
 			$parts[1] = $stringExtractor->rebuild($parts[1]);
115 127
 			$return[trim($parts[0])] = isset($parts[1]) ? trim($parts[1]) : '';
Please login to merge, or discard this patch.