Completed
Push — master ( 06252b...52b075 )
by Tom
03:06
created
src/Hook/PseudoMatcher.php 1 patch
Braces   +23 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,10 +29,14 @@  discard block
 block discarded – undo
29 29
 
30 30
 	private function attribute($pseudo, $element) {
31 31
 		$pos = strpos($pseudo, '[');
32
-		if ($pos === false) return true;
32
+		if ($pos === false) {
33
+			return true;
34
+		}
33 35
 		
34 36
 		$name = substr($pseudo, 0, $pos);
35
-		if (!is_callable([$this->dataFunction, $name])) return true;
37
+		if (!is_callable([$this->dataFunction, $name])) {
38
+			return true;
39
+		}
36 40
 
37 41
 		$bracketMatcher = new \Transphporm\Parser\BracketMatcher($pseudo);
38 42
 		$criteria = $bracketMatcher->match('[', ']');
@@ -56,16 +60,21 @@  discard block
 block discarded – undo
56 60
 	}
57 61
 
58 62
 	private function parseValue($value) {
59
-		if ($value == 'true') return true;
60
-		else if ($value == 'false') return false;
61
-		else return $value;
63
+		if ($value == 'true') {
64
+			return true;
65
+		} else if ($value == 'false') {
66
+			return false;
67
+		} else {
68
+			return $value;
69
+		}
62 70
 	}
63 71
 
64 72
 	private function getOperator($field) {
65 73
 		if ($field[strlen($field)-1] == '!') {
66 74
 			return '!';
75
+		} else {
76
+			return '';
67 77
 		}
68
-		else return '';
69 78
 	}
70 79
 
71 80
 	private function nth($pseudo, $element) {
@@ -76,8 +85,11 @@  discard block
 block discarded – undo
76 85
 			$bracketMatcher = new \Transphporm\Parser\BracketMatcher($element->getNodePath());
77 86
 			$num = $bracketMatcher->match('[', ']');
78 87
 			
79
-			if (is_callable([$this, $criteria])) return $this->$criteria($num);
80
-			else return $num == $criteria;			
88
+			if (is_callable([$this, $criteria])) {
89
+				return $this->$criteria($num);
90
+			} else {
91
+				return $num == $criteria;
92
+			}
81 93
 		}
82 94
 		return true;
83 95
 	}
@@ -94,7 +106,9 @@  discard block
 block discarded – undo
94 106
 				$xpath = new \DomXpath($element->ownerDocument);
95 107
 				
96 108
 				foreach ($xpath->query($xpathString) as $matchedElement) {
97
-					if ($element->isSameNode($matchedElement)) return false;
109
+					if ($element->isSameNode($matchedElement)) {
110
+						return false;
111
+					}
98 112
 				}
99 113
 			}
100 114
 		}
Please login to merge, or discard this patch.
src/Parser/BracketMatcher.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@
 block discarded – undo
19 19
 		$close = strpos($this->str, $closingChr, $open);
20 20
 
21 21
 		$cPos = $open+1;
22
-		while (($cPos = strpos($this->str, $openChr, $cPos+1)) !== false && $cPos < $close) $close = strpos($this->str, $closingChr, $close+1);
22
+		while (($cPos = strpos($this->str, $openChr, $cPos+1)) !== false && $cPos < $close) {
23
+			$close = strpos($this->str, $closingChr, $close+1);
24
+		}
23 25
 
24 26
 		$this->startPos = $open;
25 27
 		$this->endPos = $close;
Please login to merge, or discard this patch.
src/Parser/Value.php 1 patch
Braces   +17 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
 			$params = $bracketMatcher->match('(', ')');
29 29
 			
30 30
 			return ['name' => $name, 'params' => $params, 'endPoint' => $bracketMatcher->getClosePos()];
31
+		} else {
32
+			return ['name' => null, 'params' => $function, 'endPoint' => strlen($function)];
31 33
 		}
32
-		else return ['name' => null, 'params' => $function, 'endPoint' => strlen($function)];
33 34
 	}
34 35
 
35 36
 	public function parse($function, \DomElement $element) {
@@ -37,23 +38,26 @@  discard block
 block discarded – undo
37 38
 		if ($function && in_array($function[0], ['\'', '"'])) {
38 39
 			$finalPos = $this->findMatchingPos($function, $function[0]);
39 40
 			$result[] = $this->extractQuotedString($function[0], $function);
40
-		}
41
-		else {
41
+		} else {
42 42
 			$func = $this->parseFunction($function);
43 43
 			$finalPos = $func['endPoint'];			
44 44
 
45 45
 			if (($data = $this->callFunc($func['name'], $func['params'], $element)) !== false) {
46 46
 				$result = $this->appendToArray($result, $data);
47
-			} 
48
-			else $result[] = trim($function);
47
+			} else {
48
+				$result[] = trim($function);
49
+			}
49 50
 		}
50 51
 		$remaining = trim(substr($function, $finalPos+1));
51 52
 		return $this->parseNextValue($remaining, $result, $element);
52 53
 	}
53 54
 
54 55
 	private function appendToArray($array, $value) {
55
-		if (is_array($value)) $array += $value;
56
-		else $array[] = $value;
56
+		if (is_array($value)) {
57
+			$array += $value;
58
+		} else {
59
+			$array[] = $value;
60
+		}
57 61
 		return $array;
58 62
 	}
59 63
 
@@ -65,7 +69,9 @@  discard block
 block discarded – undo
65 69
 	}
66 70
 
67 71
 	private function parseNextValue($remaining, $result, $element) {
68
-		if (strlen($remaining) > 0 && $remaining[0] == ',') $result = array_merge($result, $this->parse(trim(substr($remaining, 1)), $element));
72
+		if (strlen($remaining) > 0 && $remaining[0] == ',') {
73
+			$result = array_merge($result, $this->parse(trim(substr($remaining, 1)), $element));
74
+		}
69 75
 		return $result;
70 76
 	}
71 77
 	
@@ -73,8 +79,9 @@  discard block
 block discarded – undo
73 79
 		$pos = $start+1;
74 80
 		$end = 0;
75 81
 		while ($end = strpos($string, $char, $pos)) {
76
-			if ($string[$end-1] === $escape) $pos = $end+1;
77
-			else {
82
+			if ($string[$end-1] === $escape) {
83
+				$pos = $end+1;
84
+			} else {
78 85
 				break;
79 86
 			}
80 87
 		}
Please login to merge, or discard this patch.