@@ -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 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $this->assertEquals(2, $conn->getNumFields()); |
275 | 275 | $this->assertEquals(0, $conn->getRowsAffected()); |
276 | 276 | |
277 | - $rowset = $conn->getArrayResult(); # array with results |
|
277 | + $rowset = $conn->getArrayResult(); # array with results |
|
278 | 278 | $row = array_shift($rowset); |
279 | 279 | |
280 | 280 | $this->assertArrayHasKey("ID", $row); |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | $conn->execute($sql); |
302 | 302 | $rowcount = count($conn->getArrayResult()); |
303 | 303 | |
304 | - $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
304 | + $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
305 | 305 | |
306 | 306 | # properties modified by execute() method |
307 | 307 | $this->assertEquals(1, $conn->getNumRows()); |
308 | 308 | $this->assertEquals(2, $conn->getNumFields()); |
309 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
309 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
310 | 310 | |
311 | 311 | $this->assertTrue($conn->commit()); |
312 | 312 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $conn->execute($sql); |
316 | 316 | $rowcount = count($conn->getArrayResult()); |
317 | 317 | |
318 | - $this->assertTrue(($rowcount === 1)); # the row is available |
|
318 | + $this->assertTrue(($rowcount === 1)); # the row is available |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -338,12 +338,12 @@ discard block |
||
338 | 338 | $conn->execute($sql); |
339 | 339 | $rowcount = count($conn->getArrayResult()); |
340 | 340 | |
341 | - $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
341 | + $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
342 | 342 | |
343 | 343 | # properties modified by execute() method |
344 | 344 | $this->assertEquals(1, $conn->getNumRows()); |
345 | 345 | $this->assertEquals(2, $conn->getNumFields()); |
346 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
346 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
347 | 347 | |
348 | 348 | $this->assertTrue($conn->rollback()); |
349 | 349 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $conn->execute($sql); |
353 | 353 | $rowcount = count($conn->getArrayResult()); |
354 | 354 | |
355 | - $this->assertNotTrue(($rowcount === 1)); # the row is not available |
|
355 | + $this->assertNotTrue(($rowcount === 1)); # the row is not available |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -384,12 +384,12 @@ discard block |
||
384 | 384 | $conn->execute($sql); |
385 | 385 | $rowcount = count($conn->getArrayResult()); |
386 | 386 | |
387 | - $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
387 | + $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
388 | 388 | |
389 | 389 | # properties modified by execute() method |
390 | 390 | $this->assertEquals(4, $conn->getNumRows()); |
391 | 391 | $this->assertEquals(2, $conn->getNumFields()); |
392 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
392 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
393 | 393 | |
394 | 394 | $this->assertTrue($conn->commit()); |
395 | 395 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $conn->execute($sql); |
399 | 399 | $rowcount = count($conn->getArrayResult()); |
400 | 400 | |
401 | - $this->assertTrue(($rowcount === 4)); # the rows are available |
|
401 | + $this->assertTrue(($rowcount === 4)); # the rows are available |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | $conn->execute($sql); |
431 | 431 | $rowcount = count($conn->getArrayResult()); |
432 | 432 | |
433 | - $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
433 | + $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
434 | 434 | |
435 | 435 | # properties modified by execute() method |
436 | 436 | $this->assertEquals(4, $conn->getNumRows()); |
437 | 437 | $this->assertEquals(2, $conn->getNumFields()); |
438 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
438 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
439 | 439 | |
440 | 440 | $this->assertTrue($conn->rollback()); |
441 | 441 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $conn->execute($sql); |
445 | 445 | $rowcount = count($conn->getArrayResult()); |
446 | 446 | |
447 | - $this->assertNotTrue(($rowcount === 4)); # the rows are not available |
|
447 | + $this->assertNotTrue(($rowcount === 4)); # the rows are not available |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | $conn->execute($sql); |
476 | 476 | $rowcount = count($conn->getArrayResult()); |
477 | 477 | |
478 | - $this->assertTrue(($rowcount === 2)); # the rows are available for now |
|
478 | + $this->assertTrue(($rowcount === 2)); # the rows are available for now |
|
479 | 479 | |
480 | 480 | # properties modified by execute() method |
481 | 481 | $this->assertEquals(2, $conn->getNumRows()); |
482 | 482 | $this->assertEquals(2, $conn->getNumFields()); |
483 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
483 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
484 | 484 | |
485 | 485 | # ends the transaction |
486 | 486 | $conn->endTransaction(); |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | $conn->execute($sql); |
491 | 491 | $rowcount = count($conn->getArrayResult()); |
492 | 492 | |
493 | - $this->assertTrue(($rowcount === 2)); # the row is available |
|
493 | + $this->assertTrue(($rowcount === 2)); # the row is available |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $conn->execute($sql); |
535 | 535 | $rowcount = count($conn->getArrayResult()); |
536 | 536 | |
537 | - $this->assertNotTrue(($rowcount === 0)); # the rows are not available |
|
537 | + $this->assertNotTrue(($rowcount === 0)); # the rows are not available |
|
538 | 538 | |
539 | 539 | # remove all work |
540 | 540 | $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')); |
@@ -126,7 +126,7 @@ |
||
126 | 126 | public function getContentsFromUrl($filename) |
127 | 127 | { |
128 | 128 | $headers = get_headers($url); |
129 | - $exists = stripos($headers[0],"200 OK") ? true : false; |
|
129 | + $exists = stripos($headers[0], "200 OK") ? true : false; |
|
130 | 130 | |
131 | 131 | if ($exists) |
132 | 132 | return file_get_contents($filename); |
@@ -90,13 +90,11 @@ discard block |
||
90 | 90 | try |
91 | 91 | { |
92 | 92 | $ctrl->addNonExistingError(); |
93 | - } |
|
94 | - catch (\Exception $e) |
|
93 | + } catch (\Exception $e) |
|
95 | 94 | { |
96 | 95 | $errorObject = ($e instanceof \LogicException); |
97 | 96 | $message = $e->getMessage(); |
98 | - } |
|
99 | - finally |
|
97 | + } finally |
|
100 | 98 | { |
101 | 99 | $this->assertTrue($errorObject, $message); |
102 | 100 | } |
@@ -109,18 +107,20 @@ discard block |
||
109 | 107 | |
110 | 108 | public function getContentsFromFile($filename) |
111 | 109 | { |
112 | - if (file_exists($filename)) |
|
113 | - return file_get_contents($filename); |
|
114 | - else |
|
115 | - $this->error(Errno::FILE_NOT_FOUND, $filename); |
|
110 | + if (file_exists($filename)) { |
|
111 | + return file_get_contents($filename); |
|
112 | + } else { |
|
113 | + $this->error(Errno::FILE_NOT_FOUND, $filename); |
|
114 | + } |
|
116 | 115 | } |
117 | 116 | |
118 | 117 | public function getContentsFromFileWithoutFilenameOnError($filename) |
119 | 118 | { |
120 | - if (file_exists($filename)) |
|
121 | - return file_get_contents($filename); |
|
122 | - else |
|
123 | - $this->error(Errno::FILE_NOT_FOUND); |
|
119 | + if (file_exists($filename)) { |
|
120 | + return file_get_contents($filename); |
|
121 | + } else { |
|
122 | + $this->error(Errno::FILE_NOT_FOUND); |
|
123 | + } |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | public function getContentsFromUrl($filename) |
@@ -128,10 +128,11 @@ discard block |
||
128 | 128 | $headers = get_headers($url); |
129 | 129 | $exists = stripos($headers[0],"200 OK") ? true : false; |
130 | 130 | |
131 | - if ($exists) |
|
132 | - return file_get_contents($filename); |
|
133 | - else |
|
134 | - $this->error("URL not found"); |
|
131 | + if ($exists) { |
|
132 | + return file_get_contents($filename); |
|
133 | + } else { |
|
134 | + $this->error("URL not found"); |
|
135 | + } |
|
135 | 136 | } |
136 | 137 | |
137 | 138 | public function addNonExistingError() |
@@ -39,13 +39,11 @@ |
||
39 | 39 | try |
40 | 40 | { |
41 | 41 | $this->assertEquals('June', Dt::getMonth(13)); |
42 | - } |
|
43 | - catch (\Exception $e) |
|
42 | + } catch (\Exception $e) |
|
44 | 43 | { |
45 | 44 | $errorObject = ($e instanceof MonthOutOfRange); |
46 | 45 | $message = $e->getMessage(); |
47 | - } |
|
48 | - finally |
|
46 | + } finally |
|
49 | 47 | { |
50 | 48 | $this->assertTrue($errorObject, $message); |
51 | 49 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function testCannotStablishConnectionWhenExists() |
69 | 69 | { |
70 | 70 | $options = $this->options; |
71 | - $options["dbhost"] = 'myserver'; // this server does not exists |
|
71 | + $options["dbhost"] = 'myserver'; // this server does not exists |
|
72 | 72 | |
73 | 73 | $errorObject = null; |
74 | 74 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public function testCannotStablishConnection() |
99 | 99 | { |
100 | 100 | $options = $this->options; |
101 | - $options["dbhost"] = 'myserver'; // this server does not exists |
|
101 | + $options["dbhost"] = 'myserver'; // this server does not exists |
|
102 | 102 | |
103 | 103 | $entity = new MyEntity(); |
104 | 104 | $gateway = new TableGateway($entity, ["other" => $options]); |
@@ -78,13 +78,11 @@ discard block |
||
78 | 78 | { |
79 | 79 | $entity = new MyEntity(); |
80 | 80 | $gateway = new TableGateway($entity, ["default" => $options]); |
81 | - } |
|
82 | - catch (\Exception $e) |
|
81 | + } catch (\Exception $e) |
|
83 | 82 | { |
84 | 83 | $errorObject = ($e instanceof \RuntimeException); |
85 | 84 | $message = $e->getMessage(); |
86 | - } |
|
87 | - finally |
|
85 | + } finally |
|
88 | 86 | { |
89 | 87 | $this->assertTrue($errorObject, $message); |
90 | 88 | } |
@@ -110,13 +108,11 @@ discard block |
||
110 | 108 | try |
111 | 109 | { |
112 | 110 | $gateway->getDb()->connect(); |
113 | - } |
|
114 | - catch (\Exception $e) |
|
111 | + } catch (\Exception $e) |
|
115 | 112 | { |
116 | 113 | $errorObject = ($e instanceof ConnectionException); |
117 | 114 | $message = $e->getMessage(); |
118 | - } |
|
119 | - finally |
|
115 | + } finally |
|
120 | 116 | { |
121 | 117 | $this->assertTrue($errorObject, $message); |
122 | 118 | $this->assertNotTrue($gateway->getDb()->isConnected()); |
@@ -145,13 +141,11 @@ discard block |
||
145 | 141 | try |
146 | 142 | { |
147 | 143 | AbstractTableGateway::getDriver('other3'); |
148 | - } |
|
149 | - catch (\Exception $e) |
|
144 | + } catch (\Exception $e) |
|
150 | 145 | { |
151 | 146 | $errorObject = ($e instanceof \RuntimeException); |
152 | 147 | $message = $e->getMessage(); |
153 | - } |
|
154 | - finally |
|
148 | + } finally |
|
155 | 149 | { |
156 | 150 | $this->assertTrue($errorObject, $message); |
157 | 151 | } |
@@ -250,13 +244,11 @@ discard block |
||
250 | 244 | try |
251 | 245 | { |
252 | 246 | $gateway->wrongDML(); |
253 | - } |
|
254 | - catch (\Exception $e) |
|
247 | + } catch (\Exception $e) |
|
255 | 248 | { |
256 | 249 | $errorObject = ($e instanceof InvalidQueryException); |
257 | 250 | $message = $e->getMessage(); |
258 | - } |
|
259 | - finally |
|
251 | + } finally |
|
260 | 252 | { |
261 | 253 | $this->assertTrue($errorObject, $message); |
262 | 254 | } |
@@ -440,7 +440,7 @@ |
||
440 | 440 | { |
441 | 441 | parent::__construct($data); |
442 | 442 | $this->setTableName("MYTABLE"); |
443 | - } |
|
443 | + } |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | class MyEntityGateway extends TableGateway |
@@ -87,24 +87,25 @@ discard block |
||
87 | 87 | { |
88 | 88 | $this->currentConnection = $connection; |
89 | 89 | $this->getDriver($connection); |
90 | - } |
|
91 | - else if (is_array($connection)) |
|
90 | + } else if (is_array($connection)) |
|
92 | 91 | { |
93 | 92 | $identifier = key($connection); |
94 | 93 | $connection_options = $connection[$identifier]; |
95 | 94 | |
96 | 95 | $this->currentConnection = $identifier; |
97 | 96 | |
98 | - if (!array_key_exists('driver', $connection_options)) |
|
99 | - throw new \RuntimeException("The database driver key has not been declared"); |
|
100 | - |
|
101 | - if (!isset(self::$drivers[$identifier])) |
|
102 | - self::$drivers[$identifier] = DriverFactory::create($connection_options); |
|
103 | - else |
|
104 | - throw new \RuntimeException("The database connection already exists"); |
|
97 | + if (!array_key_exists('driver', $connection_options)) { |
|
98 | + throw new \RuntimeException("The database driver key has not been declared"); |
|
99 | + } |
|
100 | + |
|
101 | + if (!isset(self::$drivers[$identifier])) { |
|
102 | + self::$drivers[$identifier] = DriverFactory::create($connection_options); |
|
103 | + } else { |
|
104 | + throw new \RuntimeException("The database connection already exists"); |
|
105 | + } |
|
106 | + } else { |
|
107 | + throw new \InvalidArgumentException("Invalid type given. Array or string expected"); |
|
105 | 108 | } |
106 | - else |
|
107 | - throw new \InvalidArgumentException("Invalid type given. Array or string expected"); |
|
108 | 109 | } |
109 | 110 | |
110 | 111 | /** |
@@ -118,8 +119,9 @@ discard block |
||
118 | 119 | */ |
119 | 120 | public static function getDriver($identifier) |
120 | 121 | { |
121 | - if (!array_key_exists($identifier, self::$drivers)) |
|
122 | - throw new \RuntimeException("The database connection does not exists"); |
|
122 | + if (!array_key_exists($identifier, self::$drivers)) { |
|
123 | + throw new \RuntimeException("The database connection does not exists"); |
|
124 | + } |
|
123 | 125 | |
124 | 126 | return self::$drivers[$identifier]; |
125 | 127 | } |
@@ -135,8 +137,9 @@ discard block |
||
135 | 137 | */ |
136 | 138 | public static function hasDriver($identifier) |
137 | 139 | { |
138 | - if (!array_key_exists($identifier, self::$drivers)) |
|
139 | - return false; |
|
140 | + if (!array_key_exists($identifier, self::$drivers)) { |
|
141 | + return false; |
|
142 | + } |
|
140 | 143 | |
141 | 144 | return true; |
142 | 145 | } |