Completed
Push — master ( a0fa0b...06252b )
by Tom
02:58
created
src/Hook/PseudoMatcher.php 1 patch
Braces   +32 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,17 +32,23 @@  discard block
 block discarded – undo
32 32
 		$close = strpos($string, $closingChr, $open);
33 33
 
34 34
 		$cPos = $open+1;
35
-		while (($cPos = strpos($string, $openChr, $cPos+1)) !== false && $cPos < $close) $close = strpos($string, $closingChr, $close+1);
35
+		while (($cPos = strpos($string, $openChr, $cPos+1)) !== false && $cPos < $close) {
36
+			$close = strpos($string, $closingChr, $close+1);
37
+		}
36 38
 
37 39
 		return substr($string, $open+1, $close-$open-1);
38 40
 	}
39 41
 	
40 42
 	private function attribute($pseudo, $element) {
41 43
 		$pos = strpos($pseudo, '[');
42
-		if ($pos === false) return true;
44
+		if ($pos === false) {
45
+			return true;
46
+		}
43 47
 		
44 48
 		$name = substr($pseudo, 0, $pos);
45
-		if (!is_callable([$this->dataFunction, $name])) return true;
49
+		if (!is_callable([$this->dataFunction, $name])) {
50
+			return true;
51
+		}
46 52
 
47 53
 		$criteria = $this->betweenBrackets($pseudo, '[', ']');
48 54
 
@@ -65,16 +71,21 @@  discard block
 block discarded – undo
65 71
 	}
66 72
 
67 73
 	private function parseValue($value) {
68
-		if ($value == 'true') return true;
69
-		else if ($value == 'false') return false;
70
-		else return $value;
74
+		if ($value == 'true') {
75
+			return true;
76
+		} else if ($value == 'false') {
77
+			return false;
78
+		} else {
79
+			return $value;
80
+		}
71 81
 	}
72 82
 
73 83
 	private function getOperator($field) {
74 84
 		if ($field[strlen($field)-1] == '!') {
75 85
 			return '!';
86
+		} else {
87
+			return '';
76 88
 		}
77
-		else return '';
78 89
 	}
79 90
 
80 91
 	private function nth($pseudo, $element) {
@@ -82,8 +93,11 @@  discard block
 block discarded – undo
82 93
 			$criteria = $this->getBetween($pseudo, '(', ')');
83 94
 			$num = $this->getBetween($element->getNodePath(), '[', ']');
84 95
 			
85
-			if (is_callable([$this, $criteria])) return $this->$criteria($num);
86
-			else return $num == $criteria;
96
+			if (is_callable([$this, $criteria])) {
97
+				return $this->$criteria($num);
98
+			} else {
99
+				return $num == $criteria;
100
+			}
87 101
 			
88 102
 		}
89 103
 		return true;
@@ -100,7 +114,9 @@  discard block
 block discarded – undo
100 114
 				$xpath = new \DomXpath($element->ownerDocument);
101 115
 				
102 116
 				foreach ($xpath->query($xpathString) as $matchedElement) {
103
-					if ($element->isSameNode($matchedElement)) return false;
117
+					if ($element->isSameNode($matchedElement)) {
118
+						return false;
119
+					}
104 120
 				}
105 121
 			}
106 122
 		}
@@ -121,7 +137,9 @@  discard block
 block discarded – undo
121 137
 	public function header($element)  {
122 138
 		if ($this->matches($element)) {
123 139
 			foreach ($this->pseudo as $pseudo) {
124
-				if (strpos($pseudo, 'header') === 0) return $this->getBetween($pseudo, '[', ']');
140
+				if (strpos($pseudo, 'header') === 0) {
141
+					return $this->getBetween($pseudo, '[', ']');
142
+				}
125 143
 			}
126 144
 		}
127 145
 	}
@@ -136,7 +154,9 @@  discard block
 block discarded – undo
136 154
 
137 155
 	private function getBetween($string, $start, $end) {
138 156
 		$open = strpos($string, $start);
139
-		if ($open === false) return false;
157
+		if ($open === false) {
158
+			return false;
159
+		}
140 160
 		$close = strpos($string, $end, $open);
141 161
 		return substr($string, $open+1, $close-$open-1);
142 162
 	}
Please login to merge, or discard this patch.