Completed
Push — master ( 2fb808...7b88cf )
by Richard
02:59
created
src/Parser/CssToXpath.php 1 patch
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,8 +63,11 @@  discard block
 block discarded – undo
63 63
 		$splitTokens = [];
64 64
 		$i = 0;
65 65
 		foreach ($tokens as $token) {
66
-			if ($token['type'] === $splitOn) $i++;
67
-			else $splitTokens[$i][] = $token;
66
+			if ($token['type'] === $splitOn) {
67
+				$i++;
68
+			} else {
69
+				$splitTokens[$i][] = $token;
70
+			}
68 71
 		}
69 72
 		return $splitTokens;
70 73
 	}
@@ -81,7 +84,9 @@  discard block
 block discarded – undo
81 84
 				$selector->type = $token['type'];
82 85
 				$selectors[] = $selector;
83 86
 			}
84
-			if (isset($token['value'])) $selectors[count($selectors)-1]->string = $token['value'];
87
+			if (isset($token['value'])) {
88
+				$selectors[count($selectors)-1]->string = $token['value'];
89
+			}
85 90
 		}
86 91
 		return $selectors;
87 92
 	}
@@ -89,15 +94,20 @@  discard block
 block discarded – undo
89 94
 	public function getXpath($css) {
90 95
 		foreach ($css as $key => $token) {
91 96
 			if ($token['type'] === Tokenizer::WHITESPACE &&
92
-				(isset($css[$key+1]) && $css[$key+1]['type'] === Tokenizer::GREATER_THAN)) unset($css[$key]);
93
-			else if ($token['type'] === Tokenizer::WHITESPACE &&
94
-				(isset($css[$key-1]) && $css[$key-1]['type'] === Tokenizer::GREATER_THAN)) unset($css[$key]);
97
+				(isset($css[$key+1]) && $css[$key+1]['type'] === Tokenizer::GREATER_THAN)) {
98
+				unset($css[$key]);
99
+			} else if ($token['type'] === Tokenizer::WHITESPACE &&
100
+				(isset($css[$key-1]) && $css[$key-1]['type'] === Tokenizer::GREATER_THAN)) {
101
+				unset($css[$key]);
102
+			}
95 103
 		}
96 104
 		$css = $this->splitOnToken(array_values($css), Tokenizer::COLON)[0];
97 105
 		$selectors = $this->split($css);
98 106
 		$xpath = '/';
99 107
 		foreach ($selectors as $selector) {
100
-			if (isset($this->translators[$selector->type])) $xpath .= $this->translators[$selector->type]($selector->string, $xpath);
108
+			if (isset($this->translators[$selector->type])) {
109
+				$xpath .= $this->translators[$selector->type]($selector->string, $xpath);
110
+			}
101 111
 		}
102 112
 
103 113
 		$xpath = str_replace('/[', '/*[', $xpath);
Please login to merge, or discard this patch.