Passed
Branch master (73cfe8)
by Ondřej
06:41
created
src/Ivory/Type/Std/LineSegmentType.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,12 +32,10 @@  discard block
 block discarded – undo
32 32
                 $start = $this->pointType->parseValue($m[4]);
33 33
                 $end = $this->pointType->parseValue($m[5]);
34 34
                 return LineSegment::fromEndpoints($start, $end);
35
-            }
36
-            catch (\InvalidArgumentException $e) {
35
+            } catch (\InvalidArgumentException $e) {
37 36
                 $this->throwInvalidValue($str, $e);
38 37
             }
39
-        }
40
-        else {
38
+        } else {
41 39
             $this->throwInvalidValue($str);
42 40
         }
43 41
     }
@@ -46,14 +44,12 @@  discard block
 block discarded – undo
46 44
     {
47 45
         if ($val === null) {
48 46
             return 'NULL';
49
-        }
50
-        elseif ($val instanceof LineSegment) {
47
+        } elseif ($val instanceof LineSegment) {
51 48
             return sprintf('lseg(%s,%s)',
52 49
                 $this->pointType->serializeValue($val->getStart()),
53 50
                 $this->pointType->serializeValue($val->getEnd())
54 51
             );
55
-        }
56
-        else {
52
+        } else {
57 53
             $this->throwInvalidValue($val);
58 54
         }
59 55
     }
Please login to merge, or discard this patch.
src/Ivory/Type/Std/BoxType.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,12 +32,10 @@  discard block
 block discarded – undo
32 32
                 $corner = $this->pointType->parseValue($m[2]);
33 33
                 $oppositeCorner = $this->pointType->parseValue($m[3]);
34 34
                 return Box::fromOppositeCorners($corner, $oppositeCorner);
35
-            }
36
-            catch (\InvalidArgumentException $e) {
35
+            } catch (\InvalidArgumentException $e) {
37 36
                 $this->throwInvalidValue($str, $e);
38 37
             }
39
-        }
40
-        else {
38
+        } else {
41 39
             $this->throwInvalidValue($str);
42 40
         }
43 41
     }
@@ -46,14 +44,12 @@  discard block
 block discarded – undo
46 44
     {
47 45
         if ($val === null) {
48 46
             return 'NULL';
49
-        }
50
-        elseif ($val instanceof Box) {
47
+        } elseif ($val instanceof Box) {
51 48
             return sprintf('box(%s,%s)',
52 49
                 $this->pointType->serializeValue($val->getUpperRight()),
53 50
                 $this->pointType->serializeValue($val->getLowerLeft())
54 51
             );
55
-        }
56
-        else {
52
+        } else {
57 53
             $this->throwInvalidValue($val);
58 54
         }
59 55
     }
Please login to merge, or discard this patch.
src/Ivory/Type/Std/TxIdSnapshotType.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@
 block discarded – undo
17 17
     {
18 18
         if ($str === null) {
19 19
             return null;
20
-        }
21
-        else {
20
+        } else {
22 21
             return TxIdSnapshot::fromString($str);
23 22
         }
24 23
     }
Please login to merge, or discard this patch.
src/Ivory/Type/Std/MacAddrType.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@
 block discarded – undo
22 22
 
23 23
         try {
24 24
             return MacAddr::fromString($str);
25
-        }
26
-        catch (\InvalidArgumentException $e) {
25
+        } catch (\InvalidArgumentException $e) {
27 26
             $this->throwInvalidValue($str, $e);
28 27
         }
29 28
     }
Please login to merge, or discard this patch.
src/Ivory/Type/Std/HstoreType.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
                 throw new \InvalidArgumentException('Invalid syntax of hstore value');
37 37
             }
38 38
 
39
-            $k = ($m[2][0] ? : $this->unescapeAtom($m[1][0]));
39
+            $k = ($m[2][0] ?: $this->unescapeAtom($m[1][0]));
40 40
             $v = (!empty($m[4][0]) ? null : (!empty($m[5][0]) ? $m[5][0] : $this->unescapeAtom($m[3][0])));
41 41
             $result[$k] = $v;
42 42
 
Please login to merge, or discard this patch.
Braces   +23 added lines, -46 removed lines patch added patch discarded remove patch
@@ -80,8 +80,7 @@  discard block
 block discarded – undo
80 80
         foreach ($val as $k => $v) {
81 81
             if (!$isFirst) {
82 82
                 $res .= ',';
83
-            }
84
-            else {
83
+            } else {
85 84
                 $isFirst = false;
86 85
             }
87 86
             $res .= $this->quoteAtom($k) . '=>' . $this->quoteAtom($v);
@@ -93,8 +92,7 @@  discard block
 block discarded – undo
93 92
     {
94 93
         if ($atom === null) {
95 94
             return 'NULL';
96
-        }
97
-        else {
95
+        } else {
98 96
             return '"' . strtr($atom, ['"' => '\\"', '\\' => '\\\\']) . '"';
99 97
         }
100 98
     }
@@ -132,15 +130,12 @@  discard block
 block discarded – undo
132 130
                     if ($ch == '"') {
133 131
                         $key = '';
134 132
                         $state = 1;
135
-                    }
136
-                    elseif (ctype_space($ch)) {
133
+                    } elseif (ctype_space($ch)) {
137 134
                         continue 2;
138
-                    }
139
-                    elseif (strpos($ctlChars, $ch) === false) {
135
+                    } elseif (strpos($ctlChars, $ch) === false) {
140 136
                         $key = $ch;
141 137
                         $state = 3;
142
-                    }
143
-                    else {
138
+                    } else {
144 139
                         break 2;
145 140
                     }
146 141
                     break;
@@ -148,11 +143,9 @@  discard block
 block discarded – undo
148 143
                 case 1:
149 144
                     if ($ch == '\\') {
150 145
                         $state = 2;
151
-                    }
152
-                    elseif ($ch == '"') {
146
+                    } elseif ($ch == '"') {
153 147
                         $state = 4;
154
-                    }
155
-                    else {
148
+                    } else {
156 149
                         $key .= $ch;
157 150
                     }
158 151
                     break;
@@ -165,14 +158,11 @@  discard block
 block discarded – undo
165 158
                 case 3:
166 159
                     if ($ch == '=') {
167 160
                         $state = 5;
168
-                    }
169
-                    elseif (ctype_space($ch)) {
161
+                    } elseif (ctype_space($ch)) {
170 162
                         $state = 4;
171
-                    }
172
-                    elseif (strpos($ctlChars, $ch) === false) {
163
+                    } elseif (strpos($ctlChars, $ch) === false) {
173 164
                         $key .= $ch;
174
-                    }
175
-                    else {
165
+                    } else {
176 166
                         break 2;
177 167
                     }
178 168
                     break;
@@ -180,11 +170,9 @@  discard block
 block discarded – undo
180 170
                 case 4:
181 171
                     if ($ch == '=') {
182 172
                         $state = 5;
183
-                    }
184
-                    elseif (ctype_space($ch)) {
173
+                    } elseif (ctype_space($ch)) {
185 174
                         continue 2;
186
-                    }
187
-                    else {
175
+                    } else {
188 176
                         break 2;
189 177
                     }
190 178
                     break;
@@ -192,8 +180,7 @@  discard block
 block discarded – undo
192 180
                 case 5:
193 181
                     if ($ch == '>') {
194 182
                         $state = 6;
195
-                    }
196
-                    else {
183
+                    } else {
197 184
                         break 2;
198 185
                     }
199 186
                     break;
@@ -201,16 +188,13 @@  discard block
 block discarded – undo
201 188
                 case 6:
202 189
                     if (ctype_space($ch)) {
203 190
                         continue 2;
204
-                    }
205
-                    elseif ($ch == '"') {
191
+                    } elseif ($ch == '"') {
206 192
                         $val = '';
207 193
                         $state = 7;
208
-                    }
209
-                    elseif (strpos($ctlChars, $ch) === false) {
194
+                    } elseif (strpos($ctlChars, $ch) === false) {
210 195
                         $val = $ch;
211 196
                         $state = 9;
212
-                    }
213
-                    else {
197
+                    } else {
214 198
                         break 2;
215 199
                     }
216 200
                     break;
@@ -218,11 +202,9 @@  discard block
 block discarded – undo
218 202
                 case 7:
219 203
                     if ($ch == '"') {
220 204
                         $state = 10;
221
-                    }
222
-                    elseif ($ch == '\\') {
205
+                    } elseif ($ch == '\\') {
223 206
                         $state = 8;
224
-                    }
225
-                    else {
207
+                    } else {
226 208
                         $val .= $ch;
227 209
                     }
228 210
                     break;
@@ -236,14 +218,11 @@  discard block
 block discarded – undo
236 218
                     if ($ch == ',') {
237 219
                         $result[$key] = (strcasecmp($val, 'NULL') == 0 ? null : $val);
238 220
                         $state = 0;
239
-                    }
240
-                    elseif (ctype_space($ch)) {
221
+                    } elseif (ctype_space($ch)) {
241 222
                         $state = 10;
242
-                    }
243
-                    elseif (strpos($ctlChars, $ch) === false) {
223
+                    } elseif (strpos($ctlChars, $ch) === false) {
244 224
                         $val .= $ch;
245
-                    }
246
-                    else {
225
+                    } else {
247 226
                         $state = -1;
248 227
                         break 2;
249 228
                     }
@@ -253,11 +232,9 @@  discard block
 block discarded – undo
253 232
                     if ($ch == ',') {
254 233
                         $result[$key] = $val;
255 234
                         $state = 0;
256
-                    }
257
-                    elseif (ctype_space($ch)) {
235
+                    } elseif (ctype_space($ch)) {
258 236
                         continue 2;
259
-                    }
260
-                    else {
237
+                    } else {
261 238
                         $state = -1;
262 239
                         break 2;
263 240
                     }
Please login to merge, or discard this patch.
src/Ivory/Type/Std/CircleType.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,12 +31,10 @@  discard block
 block discarded – undo
31 31
             try {
32 32
                 $center = $this->pointType->parseValue($m[4]);
33 33
                 return Circle::fromCoords($center, $m[5]);
34
-            }
35
-            catch (\InvalidArgumentException $e) {
34
+            } catch (\InvalidArgumentException $e) {
36 35
                 $this->throwInvalidValue($str, $e);
37 36
             }
38
-        }
39
-        else {
37
+        } else {
40 38
             $this->throwInvalidValue($str);
41 39
         }
42 40
     }
@@ -45,14 +43,12 @@  discard block
 block discarded – undo
45 43
     {
46 44
         if ($val === null) {
47 45
             return 'NULL';
48
-        }
49
-        elseif ($val instanceof Circle) {
46
+        } elseif ($val instanceof Circle) {
50 47
             return sprintf('circle(%s,%s)',
51 48
                 $this->pointType->serializeValue($val->getCenter()),
52 49
                 $val->getRadius()
53 50
             );
54
-        }
55
-        else {
51
+        } else {
56 52
             $this->throwInvalidValue($val);
57 53
         }
58 54
     }
Please login to merge, or discard this patch.
src/Ivory/Type/Std/TsQueryType.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@
 block discarded – undo
17 17
     {
18 18
         if ($str === null) {
19 19
             return null;
20
-        }
21
-        else {
20
+        } else {
22 21
             return TextSearchQuery::fromString($str);
23 22
         }
24 23
     }
Please login to merge, or discard this patch.
src/Ivory/Type/Std/FloatType.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -12,74 +12,74 @@
 block discarded – undo
12 12
  */
13 13
 class FloatType extends \Ivory\Type\BaseType implements ITotallyOrderedType
14 14
 {
15
-	public function parseValue($str)
16
-	{
17
-		if ($str === null) {
18
-			return null;
19
-		}
20
-		elseif (is_numeric($str)) {
21
-			return (float)$str;
22
-		}
23
-		elseif (strcasecmp($str, 'NaN') == 0) {
24
-			return NAN;
25
-		}
26
-		elseif (strcasecmp($str, 'Infinity') == 0) {
27
-			return INF;
28
-		}
29
-		elseif (strcasecmp($str, '-Infinity') == 0) {
30
-			return -INF;
31
-		}
32
-		else {
33
-			$this->throwInvalidValue($str);
34
-		}
35
-	}
15
+    public function parseValue($str)
16
+    {
17
+        if ($str === null) {
18
+            return null;
19
+        }
20
+        elseif (is_numeric($str)) {
21
+            return (float)$str;
22
+        }
23
+        elseif (strcasecmp($str, 'NaN') == 0) {
24
+            return NAN;
25
+        }
26
+        elseif (strcasecmp($str, 'Infinity') == 0) {
27
+            return INF;
28
+        }
29
+        elseif (strcasecmp($str, '-Infinity') == 0) {
30
+            return -INF;
31
+        }
32
+        else {
33
+            $this->throwInvalidValue($str);
34
+        }
35
+    }
36 36
 
37
-	public function serializeValue($val)
38
-	{
39
-		if ($val === null) {
40
-			return 'NULL';
41
-		}
42
-		elseif (is_finite($val)) {
43
-			return (string)$val;
44
-		}
45
-		elseif (is_nan($val)) {
46
-			return "'NaN'";
47
-		}
48
-		elseif ($val < 0) {
49
-			return "'-Infinity'";
50
-		}
51
-		else {
52
-			return "'Infinity'";
53
-		}
54
-	}
37
+    public function serializeValue($val)
38
+    {
39
+        if ($val === null) {
40
+            return 'NULL';
41
+        }
42
+        elseif (is_finite($val)) {
43
+            return (string)$val;
44
+        }
45
+        elseif (is_nan($val)) {
46
+            return "'NaN'";
47
+        }
48
+        elseif ($val < 0) {
49
+            return "'-Infinity'";
50
+        }
51
+        else {
52
+            return "'Infinity'";
53
+        }
54
+    }
55 55
 
56
-	public function compareValues($a, $b)
57
-	{
58
-		return self::compareFloats($a, $b);
59
-	}
56
+    public function compareValues($a, $b)
57
+    {
58
+        return self::compareFloats($a, $b);
59
+    }
60 60
 
61
-	public static function compareFloats($a, $b)
62
-	{
63
-		if ($a === null || $b === null) {
64
-			return null;
65
-		}
61
+    public static function compareFloats($a, $b)
62
+    {
63
+        if ($a === null || $b === null) {
64
+            return null;
65
+        }
66 66
 
67
-		if ($a === NAN) {
68
-			return ($b === NAN ? 0 : 1);
69
-		}
70
-		elseif ($b === NAN) {
71
-			return -1;
72
-		}
67
+        if ($a === NAN) {
68
+            return ($b === NAN ? 0 : 1);
69
+        }
70
+        elseif ($b === NAN) {
71
+            return -1;
72
+        }
73 73
 
74
-		// TODO PHP 7: use the spaceship operator
75
-		if ((float)$a < (float)$b) {
76
-			return -1;
77
-		}
78
-		elseif ((float)$a == (float)$b) {
79
-			return 0;
80
-		}
81
-		else {
82
-			return 1;
83
-		}
84
-	}
74
+        // TODO PHP 7: use the spaceship operator
75
+        if ((float)$a < (float)$b) {
76
+            return -1;
77
+        }
78
+        elseif ((float)$a == (float)$b) {
79
+            return 0;
80
+        }
81
+        else {
82
+            return 1;
83
+        }
84
+    }
85 85
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -16,20 +16,15 @@  discard block
 block discarded – undo
16 16
 	{
17 17
 		if ($str === null) {
18 18
 			return null;
19
-		}
20
-		elseif (is_numeric($str)) {
19
+		} elseif (is_numeric($str)) {
21 20
 			return (float)$str;
22
-		}
23
-		elseif (strcasecmp($str, 'NaN') == 0) {
21
+		} elseif (strcasecmp($str, 'NaN') == 0) {
24 22
 			return NAN;
25
-		}
26
-		elseif (strcasecmp($str, 'Infinity') == 0) {
23
+		} elseif (strcasecmp($str, 'Infinity') == 0) {
27 24
 			return INF;
28
-		}
29
-		elseif (strcasecmp($str, '-Infinity') == 0) {
25
+		} elseif (strcasecmp($str, '-Infinity') == 0) {
30 26
 			return -INF;
31
-		}
32
-		else {
27
+		} else {
33 28
 			$this->throwInvalidValue($str);
34 29
 		}
35 30
 	}
@@ -38,17 +33,13 @@  discard block
 block discarded – undo
38 33
 	{
39 34
 		if ($val === null) {
40 35
 			return 'NULL';
41
-		}
42
-		elseif (is_finite($val)) {
36
+		} elseif (is_finite($val)) {
43 37
 			return (string)$val;
44
-		}
45
-		elseif (is_nan($val)) {
38
+		} elseif (is_nan($val)) {
46 39
 			return "'NaN'";
47
-		}
48
-		elseif ($val < 0) {
40
+		} elseif ($val < 0) {
49 41
 			return "'-Infinity'";
50
-		}
51
-		else {
42
+		} else {
52 43
 			return "'Infinity'";
53 44
 		}
54 45
 	}
@@ -66,19 +57,16 @@  discard block
 block discarded – undo
66 57
 
67 58
 		if ($a === NAN) {
68 59
 			return ($b === NAN ? 0 : 1);
69
-		}
70
-		elseif ($b === NAN) {
60
+		} elseif ($b === NAN) {
71 61
 			return -1;
72 62
 		}
73 63
 
74 64
 		// TODO PHP 7: use the spaceship operator
75 65
 		if ((float)$a < (float)$b) {
76 66
 			return -1;
77
-		}
78
-		elseif ((float)$a == (float)$b) {
67
+		} elseif ((float)$a == (float)$b) {
79 68
 			return 0;
80
-		}
81
-		else {
69
+		} else {
82 70
 			return 1;
83 71
 		}
84 72
 	}
Please login to merge, or discard this patch.
src/Ivory/Type/Std/PointType.php 1 patch
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,13 +19,11 @@  discard block
 block discarded – undo
19 19
     {
20 20
         if ($str === null) {
21 21
             return null;
22
-        }
23
-        elseif (preg_match('~^ \s* (\()? \s* ([0-9.e+-]+) \s* , \s* ([0-9.e+-]+) \s* (?(1)\)) \s* $~ix', $str, $m) &&
22
+        } elseif (preg_match('~^ \s* (\()? \s* ([0-9.e+-]+) \s* , \s* ([0-9.e+-]+) \s* (?(1)\)) \s* $~ix', $str, $m) &&
24 23
                 is_numeric($m[2]) && is_numeric($m[3]))
25 24
         {
26 25
             return Point::fromCoords($m[2], $m[3]);
27
-        }
28
-        else {
26
+        } else {
29 27
             $this->throwInvalidValue($str);
30 28
         }
31 29
     }
@@ -38,8 +36,7 @@  discard block
 block discarded – undo
38 36
 
39 37
         if (is_array($val)) {
40 38
             $val = Point::fromCoords($val);
41
-        }
42
-        elseif (!$val instanceof Point) {
39
+        } elseif (!$val instanceof Point) {
43 40
             $this->throwInvalidValue($val);
44 41
         }
45 42
 
@@ -54,15 +51,13 @@  discard block
 block discarded – undo
54 51
 
55 52
         if (is_array($a)) {
56 53
             $a = Point::fromCoords($a);
57
-        }
58
-        elseif (!$a instanceof Point) {
54
+        } elseif (!$a instanceof Point) {
59 55
             throw new IncomparableException('$a is not a ' . Point::class);
60 56
         }
61 57
 
62 58
         if (is_array($b)) {
63 59
             $b = Point::fromCoords($b);
64
-        }
65
-        elseif (!$b instanceof Point) {
60
+        } elseif (!$b instanceof Point) {
66 61
             throw new IncomparableException('$b is not a ' . Point::class);
67 62
         }
68 63
 
@@ -72,8 +67,7 @@  discard block
 block discarded – undo
72 67
         $xComp = FloatType::compareFloats($ac[0], $bc[0]);
73 68
         if ($xComp !== 0) {
74 69
             return $xComp;
75
-        }
76
-        else {
70
+        } else {
77 71
             return FloatType::compareFloats($ac[1], $bc[1]);
78 72
         }
79 73
     }
Please login to merge, or discard this patch.