@@ -74,7 +74,7 @@ |
||
74 | 74 | public function listen(Array $eventHandlers = array()) |
75 | 75 | { |
76 | 76 | $event = $eventHandlers; |
77 | - $clousure = function(){}; |
|
77 | + $clousure = function() {}; |
|
78 | 78 | |
79 | 79 | if (!array_key_exists('success', $event)) |
80 | 80 | $event["success"] = $clousure; |
@@ -76,11 +76,13 @@ discard block |
||
76 | 76 | $event = $eventHandlers; |
77 | 77 | $clousure = function(){}; |
78 | 78 | |
79 | - if (!array_key_exists('success', $event)) |
|
80 | - $event["success"] = $clousure; |
|
79 | + if (!array_key_exists('success', $event)) { |
|
80 | + $event["success"] = $clousure; |
|
81 | + } |
|
81 | 82 | |
82 | - if (!array_key_exists('error', $event)) |
|
83 | - $event["error"] = $clousure; |
|
83 | + if (!array_key_exists('error', $event)) { |
|
84 | + $event["error"] = $clousure; |
|
85 | + } |
|
84 | 86 | |
85 | 87 | $listener = false; |
86 | 88 | |
@@ -90,8 +92,7 @@ discard block |
||
90 | 92 | $this->error($errno, socket_strerror($errno)); |
91 | 93 | |
92 | 94 | throw new \RuntimeException("Could not set socket to listen"); |
93 | - } |
|
94 | - else { |
|
95 | + } else { |
|
95 | 96 | |
96 | 97 | echo "\n"; |
97 | 98 | echo "Server Started : " . date('Y-m-d H:i:s') . "\n"; |
@@ -114,8 +115,9 @@ discard block |
||
114 | 115 | socket_close($spawn); |
115 | 116 | } |
116 | 117 | |
117 | - if (!$listener) |
|
118 | - call_user_func($event["error"], $this->getLastError()); |
|
118 | + if (!$listener) { |
|
119 | + call_user_func($event["error"], $this->getLastError()); |
|
120 | + } |
|
119 | 121 | |
120 | 122 | return $listener; |
121 | 123 | } |
@@ -84,12 +84,10 @@ discard block |
||
84 | 84 | |
85 | 85 | try { |
86 | 86 | $conn->disconnect(); |
87 | - } |
|
88 | - catch (\Exception $e) |
|
87 | + } catch (\Exception $e) |
|
89 | 88 | { |
90 | 89 | $errorObject = ($e instanceof \LogicException); |
91 | - } |
|
92 | - finally |
|
90 | + } finally |
|
93 | 91 | { |
94 | 92 | $this->assertNotTrue($conn->isConnected()); |
95 | 93 | $this->assertTrue($errorObject, $e->getMessage()); |
@@ -125,12 +123,10 @@ discard block |
||
125 | 123 | |
126 | 124 | try { |
127 | 125 | $conn->reconnect(); |
128 | - } |
|
129 | - catch (\Exception $e) |
|
126 | + } catch (\Exception $e) |
|
130 | 127 | { |
131 | 128 | $errorObject = ($e instanceof \LogicException); |
132 | - } |
|
133 | - finally |
|
129 | + } finally |
|
134 | 130 | { |
135 | 131 | $this->assertTrue($errorObject, $e->getMessage()); |
136 | 132 | $this->assertNotTrue($conn->isConnected()); |
@@ -156,13 +152,11 @@ discard block |
||
156 | 152 | try |
157 | 153 | { |
158 | 154 | $conn->connect(); |
159 | - } |
|
160 | - catch (\Exception $e) |
|
155 | + } catch (\Exception $e) |
|
161 | 156 | { |
162 | 157 | $errorObject = ($e instanceof ConnectionException); |
163 | 158 | $message = $e->getMessage(); |
164 | - } |
|
165 | - finally |
|
159 | + } finally |
|
166 | 160 | { |
167 | 161 | $this->assertTrue($errorObject, $message); |
168 | 162 | $this->assertNotTrue($conn->isConnected()); |
@@ -242,13 +236,11 @@ discard block |
||
242 | 236 | { |
243 | 237 | $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('Hello world!')"; |
244 | 238 | $conn->execute($sql); |
245 | - } |
|
246 | - catch (\Exception $e) |
|
239 | + } catch (\Exception $e) |
|
247 | 240 | { |
248 | 241 | $errorObject = ($e instanceof InvalidQueryException); |
249 | 242 | $message = $e->getMessage(); |
250 | - } |
|
251 | - finally |
|
243 | + } finally |
|
252 | 244 | { |
253 | 245 | $this->assertTrue($errorObject, $message); |
254 | 246 | } |
@@ -517,8 +509,7 @@ discard block |
||
517 | 509 | |
518 | 510 | $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')"; |
519 | 511 | $conn->execute($sql); |
520 | - } |
|
521 | - catch (InvalidQueryException $e) |
|
512 | + } catch (InvalidQueryException $e) |
|
522 | 513 | { |
523 | 514 | $message = $e->getMessage(); |
524 | 515 | #·not necessary! |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | public function testCannotStablishConnection() |
146 | 146 | { |
147 | 147 | $options = $this->options; |
148 | - $options["dbhost"] = 'myserver'; // this server does not exists |
|
148 | + $options["dbhost"] = 'myserver'; // this server does not exists |
|
149 | 149 | |
150 | 150 | $conn = new MySQL($options); |
151 | 151 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $this->assertEquals(2, $conn->getNumFields()); |
274 | 274 | $this->assertEquals(0, $conn->getRowsAffected()); |
275 | 275 | |
276 | - $rowset = $conn->getArrayResult(); # array with results |
|
276 | + $rowset = $conn->getArrayResult(); # array with results |
|
277 | 277 | $row = array_shift($rowset); |
278 | 278 | |
279 | 279 | $this->assertArrayHasKey("ID", $row); |
@@ -300,12 +300,12 @@ discard block |
||
300 | 300 | $conn->execute($sql); |
301 | 301 | $rowcount = count($conn->getArrayResult()); |
302 | 302 | |
303 | - $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
303 | + $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
304 | 304 | |
305 | 305 | # properties modified by execute() method |
306 | 306 | $this->assertEquals(1, $conn->getNumRows()); |
307 | 307 | $this->assertEquals(2, $conn->getNumFields()); |
308 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
308 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
309 | 309 | |
310 | 310 | $this->assertTrue($conn->commit()); |
311 | 311 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $conn->execute($sql); |
315 | 315 | $rowcount = count($conn->getArrayResult()); |
316 | 316 | |
317 | - $this->assertTrue(($rowcount === 1)); # the row is available |
|
317 | + $this->assertTrue(($rowcount === 1)); # the row is available |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | $conn->execute($sql); |
338 | 338 | $rowcount = count($conn->getArrayResult()); |
339 | 339 | |
340 | - $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
340 | + $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
341 | 341 | |
342 | 342 | # properties modified by execute() method |
343 | 343 | $this->assertEquals(1, $conn->getNumRows()); |
344 | 344 | $this->assertEquals(2, $conn->getNumFields()); |
345 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
345 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
346 | 346 | |
347 | 347 | $this->assertTrue($conn->rollback()); |
348 | 348 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $conn->execute($sql); |
352 | 352 | $rowcount = count($conn->getArrayResult()); |
353 | 353 | |
354 | - $this->assertNotTrue(($rowcount === 1)); # the row is not available |
|
354 | + $this->assertNotTrue(($rowcount === 1)); # the row is not available |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -383,12 +383,12 @@ discard block |
||
383 | 383 | $conn->execute($sql); |
384 | 384 | $rowcount = count($conn->getArrayResult()); |
385 | 385 | |
386 | - $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
386 | + $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
387 | 387 | |
388 | 388 | # properties modified by execute() method |
389 | 389 | $this->assertEquals(4, $conn->getNumRows()); |
390 | 390 | $this->assertEquals(2, $conn->getNumFields()); |
391 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
391 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
392 | 392 | |
393 | 393 | $this->assertTrue($conn->commit()); |
394 | 394 | |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | $conn->execute($sql); |
398 | 398 | $rowcount = count($conn->getArrayResult()); |
399 | 399 | |
400 | - $this->assertTrue(($rowcount === 4)); # the row is available |
|
400 | + $this->assertTrue(($rowcount === 4)); # the row is available |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
@@ -429,12 +429,12 @@ discard block |
||
429 | 429 | $conn->execute($sql); |
430 | 430 | $rowcount = count($conn->getArrayResult()); |
431 | 431 | |
432 | - $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
432 | + $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
433 | 433 | |
434 | 434 | # properties modified by execute() method |
435 | 435 | $this->assertEquals(4, $conn->getNumRows()); |
436 | 436 | $this->assertEquals(2, $conn->getNumFields()); |
437 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
437 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
438 | 438 | |
439 | 439 | $this->assertTrue($conn->rollback()); |
440 | 440 | |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | $conn->execute($sql); |
444 | 444 | $rowcount = count($conn->getArrayResult()); |
445 | 445 | |
446 | - $this->assertNotTrue(($rowcount === 4)); # the row is available |
|
446 | + $this->assertNotTrue(($rowcount === 4)); # the row is available |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -474,12 +474,12 @@ discard block |
||
474 | 474 | $conn->execute($sql); |
475 | 475 | $rowcount = count($conn->getArrayResult()); |
476 | 476 | |
477 | - $this->assertTrue(($rowcount === 2)); # the rows are available for now |
|
477 | + $this->assertTrue(($rowcount === 2)); # the rows are available for now |
|
478 | 478 | |
479 | 479 | # properties modified by execute() method |
480 | 480 | $this->assertEquals(2, $conn->getNumRows()); |
481 | 481 | $this->assertEquals(2, $conn->getNumFields()); |
482 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
482 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
483 | 483 | |
484 | 484 | # ends the transaction |
485 | 485 | $conn->endTransaction(); |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | $conn->execute($sql); |
490 | 490 | $rowcount = count($conn->getArrayResult()); |
491 | 491 | |
492 | - $this->assertTrue(($rowcount === 2)); # the row is available |
|
492 | + $this->assertTrue(($rowcount === 2)); # the row is available |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $conn->execute($sql); |
534 | 534 | $rowcount = count($conn->getArrayResult()); |
535 | 535 | |
536 | - $this->assertNotTrue(($rowcount === 0)); # the rows are not available |
|
536 | + $this->assertNotTrue(($rowcount === 0)); # the rows are not available |
|
537 | 537 | |
538 | 538 | # remove all work |
539 | 539 | $conn->execute("DROP TABLE MYTABLE"); |
@@ -127,8 +127,9 @@ |
||
127 | 127 | { |
128 | 128 | $codes = $this->httpStatusCodes; |
129 | 129 | |
130 | - if (!in_array($code, array_keys($codes))) |
|
131 | - throw new \RuntimeException("Status code not supported"); |
|
130 | + if (!in_array($code, array_keys($codes))) { |
|
131 | + throw new \RuntimeException("Status code not supported"); |
|
132 | + } |
|
132 | 133 | |
133 | 134 | return $this->httpStatusCodes[$code]; |
134 | 135 | } |
@@ -56,13 +56,11 @@ |
||
56 | 56 | try |
57 | 57 | { |
58 | 58 | $text = $http->getStatusText(65431); |
59 | - } |
|
60 | - catch (\Exception $e) |
|
59 | + } catch (\Exception $e) |
|
61 | 60 | { |
62 | 61 | $errorObject = ($e instanceof \RuntimeException); |
63 | 62 | $message = $e->getMessage(); |
64 | - } |
|
65 | - finally |
|
63 | + } finally |
|
66 | 64 | { |
67 | 65 | $this->assertTrue($errorObject, $message); |
68 | 66 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | break; |
95 | 95 | |
96 | 96 | case self::LAST_YEAR: |
97 | - $year = ((int) date('Y'))- 1; |
|
97 | + $year = ((int) date('Y')) - 1; |
|
98 | 98 | break; |
99 | 99 | |
100 | 100 | default: |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $d->setDate($year, (int) $d->format('m'), (int) $d->format('d')); |
143 | 143 | } |
144 | 144 | |
145 | - $d->add(new \DateInterval('P'.($day - 1).'D')); |
|
145 | + $d->add(new \DateInterval('P' . ($day - 1) . 'D')); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | return $d; |
@@ -63,8 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public static function getMonth($month_number) |
65 | 65 | { |
66 | - if (!array_key_exists($month_number, self::MONTHS)) |
|
67 | - throw new Exception\MonthOutOfRange("Invalid Month"); |
|
66 | + if (!array_key_exists($month_number, self::MONTHS)) { |
|
67 | + throw new Exception\MonthOutOfRange("Invalid Month"); |
|
68 | + } |
|
68 | 69 | |
69 | 70 | return self::MONTHS[$month_number]; |
70 | 71 | } |
@@ -78,14 +79,17 @@ discard block |
||
78 | 79 | */ |
79 | 80 | public static function create(array $date = []) |
80 | 81 | { |
81 | - if (!array_key_exists('day', $date)) |
|
82 | - $date["day"] = self::TODAY; |
|
82 | + if (!array_key_exists('day', $date)) { |
|
83 | + $date["day"] = self::TODAY; |
|
84 | + } |
|
83 | 85 | |
84 | - if (!array_key_exists('month', $date)) |
|
85 | - $date["month"] = self::THIS_MONTH; |
|
86 | + if (!array_key_exists('month', $date)) { |
|
87 | + $date["month"] = self::THIS_MONTH; |
|
88 | + } |
|
86 | 89 | |
87 | - if (!array_key_exists('year', $date)) |
|
88 | - $date["year"] = self::THIS_YEAR; |
|
90 | + if (!array_key_exists('year', $date)) { |
|
91 | + $date["year"] = self::THIS_YEAR; |
|
92 | + } |
|
89 | 93 | |
90 | 94 | switch ($date['year']) |
91 | 95 | { |
@@ -130,13 +134,13 @@ discard block |
||
130 | 134 | break; |
131 | 135 | } |
132 | 136 | |
133 | - if (is_string($day)) |
|
134 | - $d = new \DateTime("$day $month $year"); |
|
135 | - else |
|
137 | + if (is_string($day)) { |
|
138 | + $d = new \DateTime("$day $month $year"); |
|
139 | + } else |
|
136 | 140 | { |
137 | - if (in_array($month, self::MONTHS)) |
|
138 | - $d = new \DateTime("first day of $month $year"); |
|
139 | - else |
|
141 | + if (in_array($month, self::MONTHS)) { |
|
142 | + $d = new \DateTime("first day of $month $year"); |
|
143 | + } else |
|
140 | 144 | { |
141 | 145 | $d = new \DateTime("first day of $month"); |
142 | 146 | $d->setDate($year, (int) $d->format('m'), (int) $d->format('d')); |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | $again = true; |
40 | 40 | $new_config[$param . $glue . $key] = $value; |
41 | 41 | } |
42 | + } else { |
|
43 | + $new_config[$param] = $configure; |
|
42 | 44 | } |
43 | - else |
|
44 | - $new_config[$param] = $configure; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | return (!$again) ? $new_config : self::toUnidimensional($new_config, $glue); |
@@ -64,15 +64,17 @@ discard block |
||
64 | 64 | |
65 | 65 | do |
66 | 66 | { |
67 | - if (array_key_exists($key, $haystack)) |
|
68 | - $haystack = $haystack[$key]; |
|
69 | - else |
|
70 | - return $value; |
|
67 | + if (array_key_exists($key, $haystack)) { |
|
68 | + $haystack = $haystack[$key]; |
|
69 | + } else { |
|
70 | + return $value; |
|
71 | + } |
|
71 | 72 | |
72 | 73 | $key = count($needle) ? array_shift($needle) : NULL; |
73 | 74 | |
74 | - if (is_null($key)) |
|
75 | - return $haystack; |
|
75 | + if (is_null($key)) { |
|
76 | + return $haystack; |
|
77 | + } |
|
76 | 78 | |
77 | 79 | } while (!is_null($key)); |
78 | 80 | } |