Completed
Pull Request — master (#112)
by Richard
02:58
created
src/Parser/Sheet.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 			}
29 29
 
30 30
 			$selector = trim(substr($this->tss, $pos, $next-$pos));
31
-			$pos =  strpos($this->tss, '}', $next)+1;
31
+			$pos = strpos($this->tss, '}', $next)+1;
32 32
 			$newRules = $this->cssToRules($selector, count($rules)+$indexStart, $this->getProperties(trim(substr($this->tss, $next+1, $pos-2-$next))));
33 33
 			$rules = $this->writeRule($rules, $newRules);
34 34
 		}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	private function processingInstructions($tss, $pos, $next, $indexStart) {
63 63
 		$rules = [];
64 64
 		while (($atPos = strpos($tss, '@', $pos)) !== false) {
65
-			if ($atPos  <= (int) $next) {
65
+			if ($atPos <= (int) $next) {
66 66
 				$spacePos = strpos($tss, ' ', $atPos);
67 67
 				$funcName = substr($tss, $atPos+1, $spacePos-$atPos-1);
68 68
 				$pos = strpos($tss, ';', $spacePos);
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
 	}
79 79
 
80 80
 	private function import($args, $indexStart) {
81
-		if (is_file(trim($args,'\'" '))) $fileName = trim($args,'\'" ');
81
+		if (is_file(trim($args, '\'" '))) $fileName = trim($args, '\'" ');
82 82
 		else $fileName = $this->valueParser->parse($args)[0];
83 83
 
84
-		if (is_file($this->baseDir . $fileName)) $tssFile = $this->baseDir . $fileName;
84
+		if (is_file($this->baseDir.$fileName)) $tssFile = $this->baseDir.$fileName;
85 85
 		elseif (is_file($fileName)) $tssFile = $fileName;
86
-		else throw new \Exception('Imported TSS File "' . $fileName .'" does not exist');
86
+		else throw new \Exception('Imported TSS File "'.$fileName.'" does not exist');
87 87
 
88 88
 		$sheet = new Sheet(file_get_contents($tssFile), $this->baseDir, $this->xPath, $this->valueParser);
89 89
 		return $sheet->parse(0, [], $indexStart);
Please login to merge, or discard this patch.
Braces   +25 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  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 40
 		return $rules;
39 41
 	}
@@ -68,8 +70,7 @@  discard block
 block discarded – undo
68 70
 				$pos = strpos($tss, ';', $spacePos);
69 71
 				$args = substr($tss, $spacePos+1, $pos-$spacePos-1);
70 72
 				$rules = array_merge($rules, $this->$funcName($args, $indexStart));
71
-			}
72
-			else {
73
+			} else {
73 74
 				break;
74 75
 			}
75 76
 		}
@@ -78,12 +79,19 @@  discard block
 block discarded – undo
78 79
 	}
79 80
 
80 81
 	private function import($args, $indexStart) {
81
-		if (is_file(trim($args,'\'" '))) $fileName = trim($args,'\'" ');
82
-		else $fileName = $this->valueParser->parse($args)[0];
82
+		if (is_file(trim($args,'\'" '))) {
83
+			$fileName = trim($args,'\'" ');
84
+		} else {
85
+			$fileName = $this->valueParser->parse($args)[0];
86
+		}
83 87
 
84
-		if (is_file($this->baseDir . $fileName)) $tssFile = $this->baseDir . $fileName;
85
-		elseif (is_file($fileName)) $tssFile = $fileName;
86
-		else throw new \Exception('Imported TSS File "' . $fileName .'" does not exist');
88
+		if (is_file($this->baseDir . $fileName)) {
89
+			$tssFile = $this->baseDir . $fileName;
90
+		} elseif (is_file($fileName)) {
91
+			$tssFile = $fileName;
92
+		} else {
93
+			throw new \Exception('Imported TSS File "' . $fileName .'" does not exist');
94
+		}
87 95
 
88 96
 		$sheet = new Sheet(file_get_contents($tssFile), $this->baseDir, $this->xPath, $this->valueParser);
89 97
 		return $sheet->parse(0, [], $indexStart);
@@ -91,7 +99,9 @@  discard block
 block discarded – undo
91 99
 
92 100
 	private function sortRules($a, $b) {
93 101
 		//If they have the same depth, compare on index
94
-		if ($a->depth === $b->depth) return $a->index < $b->index ? -1 : 1;
102
+		if ($a->depth === $b->depth) {
103
+			return $a->index < $b->index ? -1 : 1;
104
+		}
95 105
 
96 106
 		return ($a->depth < $b->depth) ? -1 : 1;
97 107
 	}
@@ -100,7 +110,9 @@  discard block
 block discarded – undo
100 110
 		$pos = 0;
101 111
 		while (($pos = strpos($str, $open, $pos)) !== false) {
102 112
 			$end = strpos($str, $close, $pos);
103
-			if ($end === false) break;
113
+			if ($end === false) {
114
+				break;
115
+			}
104 116
 			$str = substr_replace($str, '', $pos, $end-$pos+2);
105 117
 		}
106 118
 
@@ -113,7 +125,9 @@  discard block
 block discarded – undo
113 125
 		$return = [];
114 126
 
115 127
 		foreach ($rules as $rule) {
116
-			if (trim($rule) === '') continue;
128
+			if (trim($rule) === '') {
129
+				continue;
130
+			}
117 131
 			$parts = explode(':', $rule, 2);
118 132
 			$parts[1] = $stringExtractor->rebuild($parts[1]);
119 133
 			$return[trim($parts[0])] = isset($parts[1]) ? trim($parts[1]) : '';
Please login to merge, or discard this patch.
src/TSSFunction/Template.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@
 block discarded – undo
27 27
 		$selector = $this->readArray($args, 1);
28 28
 		$tss = $this->readArray($args, 2);
29 29
 
30
-		if (is_file($this->baseDir . $args[0])) $xmlFile = $this->baseDir . $args[0];
30
+		if (is_file($this->baseDir.$args[0])) $xmlFile = $this->baseDir.$args[0];
31 31
 		elseif (is_file($args[0])) $xmlFile = $args[0];
32
-		else throw new \Exception('XML File "' . $args[0] .'" does not exist');
32
+		else throw new \Exception('XML File "'.$args[0].'" does not exist');
33 33
 
34
-		$newTemplate = new \Transphporm\Builder($xmlFile, $tss ? $this->baseDir . $tss : null);
34
+		$newTemplate = new \Transphporm\Builder($xmlFile, $tss ? $this->baseDir.$tss : null);
35 35
 
36 36
 		$doc = $newTemplate->output($this->elementData->getData($element), true)->body;
37 37
 		if ($selector != '') return $this->templateSubsection($doc, $selector);
Please login to merge, or discard this patch.
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,14 +27,20 @@  discard block
 block discarded – undo
27 27
 		$selector = $this->readArray($args, 1);
28 28
 		$tss = $this->readArray($args, 2);
29 29
 
30
-		if (is_file($this->baseDir . $args[0])) $xmlFile = $this->baseDir . $args[0];
31
-		elseif (is_file($args[0])) $xmlFile = $args[0];
32
-		else throw new \Exception('XML File "' . $args[0] .'" does not exist');
30
+		if (is_file($this->baseDir . $args[0])) {
31
+			$xmlFile = $this->baseDir . $args[0];
32
+		} elseif (is_file($args[0])) {
33
+			$xmlFile = $args[0];
34
+		} else {
35
+			throw new \Exception('XML File "' . $args[0] .'" does not exist');
36
+		}
33 37
 
34 38
 		$newTemplate = new \Transphporm\Builder($xmlFile, $tss ? $this->baseDir . $tss : null);
35 39
 
36 40
 		$doc = $newTemplate->output($this->elementData->getData($element), true)->body;
37
-		if ($selector != '') return $this->templateSubsection($doc, $selector);
41
+		if ($selector != '') {
42
+			return $this->templateSubsection($doc, $selector);
43
+		}
38 44
 
39 45
 		return $this->getTemplateContent($doc, $tss);
40 46
 
@@ -64,7 +70,9 @@  discard block
 block discarded – undo
64 70
 
65 71
 	private function getClonedElement($node, $tss) {
66 72
 		$clone = $node->cloneNode(true);
67
-		if ($tss != null && $clone instanceof \DomElement) $clone->setAttribute('transphporm', 'includedtemplate');
73
+		if ($tss != null && $clone instanceof \DomElement) {
74
+			$clone->setAttribute('transphporm', 'includedtemplate');
75
+		}
68 76
 		return $clone;
69 77
 	}
70 78
 }
Please login to merge, or discard this patch.