Passed
Push — master ( 4326dc...a492d1 )
by Maike
02:09
created
lib/Connection.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -96,7 +96,9 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function connection($connectionString, $username, $password)
98 98
     {
99
-        if (is_null($this->getCurrentConnectionName())) throw new \Exception('Conexão não setada.');
99
+        if (is_null($this->getCurrentConnectionName())) {
100
+         throw new \Exception('Conexão não setada.');
101
+        }
100 102
 
101 103
         try {
102 104
             $connectionName = $this->getCurrentConnectionName();
@@ -199,8 +201,12 @@  discard block
 block discarded – undo
199 201
      */
200 202
     final public function changeSchema($schema = null)
201 203
     {
202
-        if (!is_string($schema)) throw new \InvalidArgumentException('The parameter don\'t is an String.');
203
-        if ($this->driver == 'mysql') throw new \InvalidArgumentException('This driver not supported schemas.');
204
+        if (!is_string($schema)) {
205
+         throw new \InvalidArgumentException('The parameter don\'t is an String.');
206
+        }
207
+        if ($this->driver == 'mysql') {
208
+         throw new \InvalidArgumentException('This driver not supported schemas.');
209
+        }
204 210
 
205 211
         $this->getConnection()->exec("SET search_path TO '$schema';");
206 212
         return $this;
Please login to merge, or discard this patch.
lib/Config.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@
 block discarded – undo
134 134
                 'password' => $this->_password[$connectionName],
135 135
                 'charset' => $this->_charset[$connectionName],
136 136
                 'schema' => $this->_schema[$connectionName]];
137
-        } else {
137
+        }else {
138 138
             throw new \Exception("The connection name $connectionName is not set.");
139 139
         }
140 140
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -71,15 +71,27 @@
 block discarded – undo
71 71
                                 $defaultSchema = null)
72 72
     {
73 73
         #Begin: Verify if all parameters send is valid.
74
-        if (!is_string($driver) || !in_array($driver, self::DRIVERS)) throw new \Exception("The driver $driver don't supported.");
75
-        if (!is_string($username) || empty($username)) throw new \Exception("Invalid username.");
76
-        if (!is_string($password) || empty($password)) throw new \Exception("Invalid password.");
77
-        if (!is_string($host) || empty($host)) throw new \Exception("Invalid host.");
78
-        if (!is_string($database) || empty($database)) throw new \Exception("Invalid database name.");
74
+        if (!is_string($driver) || !in_array($driver, self::DRIVERS)) {
75
+         throw new \Exception("The driver $driver don't supported.");
76
+        }
77
+        if (!is_string($username) || empty($username)) {
78
+         throw new \Exception("Invalid username.");
79
+        }
80
+        if (!is_string($password) || empty($password)) {
81
+         throw new \Exception("Invalid password.");
82
+        }
83
+        if (!is_string($host) || empty($host)) {
84
+         throw new \Exception("Invalid host.");
85
+        }
86
+        if (!is_string($database) || empty($database)) {
87
+         throw new \Exception("Invalid database name.");
88
+        }
79 89
         $this->validatesConnectionName($connectionName);
80 90
 
81 91
         $port = is_null($port) ? '' : (int)$port;
82
-        if (!is_null($port) && !is_int($port)) throw new \Exception("Invalid port format.");
92
+        if (!is_null($port) && !is_int($port)) {
93
+         throw new \Exception("Invalid port format.");
94
+        }
83 95
         #Constructor of the connection string
84 96
         $this->_connectionString[$connectionName] = "$driver:host=$host;dbname=$database;port=$port;";
85 97
         $this->_username[$connectionName] = $username;
Please login to merge, or discard this patch.
lib/Model.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
         if (!empty($this->_data[$key])) {
136 136
             $sql = 'UPDATE ' . $_tableName . ' SET ';
137 137
 
138
-            if (count($this->_newData) <= 0){
139
-                Error::create('Don\'t have alter data.', 1,'InvalidArgumentException');
138
+            if (count($this->_newData) <= 0) {
139
+                Error::create('Don\'t have alter data.', 1, 'InvalidArgumentException');
140 140
                 return false;
141 141
             }
142 142
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
             $this->_newData[] = $this->{$key};
147 147
 
148 148
             $update = true;
149
-        } else {
149
+        }else {
150 150
             /**
151 151
              * Insert case don't have primary key
152 152
              */
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
         $insert = $this->Connection->getConnection()->prepare($sql);
163 163
         $this->burnError($insert);
164 164
 
165
-        $this->_newData = array_map(function ($data){
166
-            if(is_bool($data) and $data === false)  $data = 0;
165
+        $this->_newData = array_map(function($data) {
166
+            if (is_bool($data) and $data === false)  $data = 0;
167 167
 
168 168
             return $data;
169 169
         }, $this->_newData);
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         return true;
193 193
     }
194 194
 
195
-    private function burnError($statment){
195
+    private function burnError($statment) {
196 196
         if (!is_null($statment->errorInfo()[1])) throw new \Exception($statment->errorInfo()[2], $statment->errorInfo()[1]);
197 197
     }
198 198
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 
218 218
         $instance = self::$_instance;
219 219
 
220
-        if (is_callable($this->triggerBefore)) ($this->triggerBefore)();;
220
+        if (is_callable($this->triggerBefore)) ($this->triggerBefore)(); ;
221 221
 
222 222
         $start = microtime(true);
223 223
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 
374 374
         if ($instance->Connection->getConnection()->lastInsertId() == '-1' || $instance->Connection->getConnection()->lastInsertId() == 0) {
375 375
             return false;
376
-        } else {
376
+        }else {
377 377
             return $instance;
378 378
         }
379 379
     }
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 
527 527
         if ($match) {
528 528
             $this->_data = $objetos = $consulta->fetchAll(\PDO::FETCH_CLASS, get_called_class());
529
-        } else {
529
+        }else {
530 530
             $objetos = $consulta->rowCount();
531 531
         }
532 532
 
Please login to merge, or discard this patch.
Braces   +87 added lines, -29 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
             $this->cleanNewData();
56 56
 
57 57
             if (!is_null($object)) {
58
-                if (!is_array($object)) throw new \InvalidArgumentException('Accept only array from object');
58
+                if (!is_array($object)) {
59
+                 throw new \InvalidArgumentException('Accept only array from object');
60
+                }
59 61
 
60 62
                 $this->_data = $object;
61 63
                 $this->_newData = $object;
@@ -82,9 +84,13 @@  discard block
 block discarded – undo
82 84
      */
83 85
     public function __get($name)
84 86
     {
85
-        if (strtolower($name) == 'errors') return Error::instance();
87
+        if (strtolower($name) == 'errors') {
88
+         return Error::instance();
89
+        }
86 90
 
87
-        if (!key_exists($name, $this->_data)) throw new \Exception("The attribute $name not found.");
91
+        if (!key_exists($name, $this->_data)) {
92
+         throw new \Exception("The attribute $name not found.");
93
+        }
88 94
 
89 95
         return $this->_data[$name];
90 96
     }
@@ -156,14 +162,18 @@  discard block
 block discarded – undo
156 162
             $sql .= " ($repeat); ";
157 163
         }
158 164
 
159
-        if (is_callable($this->triggerBefore)) ($this->triggerBefore)();
165
+        if (is_callable($this->triggerBefore)) {
166
+         ($this->triggerBefore)();
167
+        }
160 168
 
161 169
         $start = microtime(true);
162 170
         $insert = $this->Connection->getConnection()->prepare($sql);
163 171
         $this->burnError($insert);
164 172
 
165 173
         $this->_newData = array_map(function ($data){
166
-            if(is_bool($data) and $data === false)  $data = 0;
174
+            if(is_bool($data) and $data === false) {
175
+             $data = 0;
176
+            }
167 177
 
168 178
             return $data;
169 179
         }, $this->_newData);
@@ -174,7 +184,9 @@  discard block
 block discarded – undo
174 184
 
175 185
         $this->Connection->setPerformedQuery($insert->queryString, round(($end - $start), 5));
176 186
 
177
-        if (is_callable($this->triggerAfter)) ($this->triggerAfter)();
187
+        if (is_callable($this->triggerAfter)) {
188
+         ($this->triggerAfter)();
189
+        }
178 190
 
179 191
         if ($update) {
180 192
             $this->burnError($insert);
@@ -193,7 +205,9 @@  discard block
 block discarded – undo
193 205
     }
194 206
 
195 207
     private function burnError($statment){
196
-        if (!is_null($statment->errorInfo()[1])) throw new \Exception($statment->errorInfo()[2], $statment->errorInfo()[1]);
208
+        if (!is_null($statment->errorInfo()[1])) {
209
+         throw new \Exception($statment->errorInfo()[2], $statment->errorInfo()[1]);
210
+        }
197 211
     }
198 212
 
199 213
     /**
@@ -208,16 +222,23 @@  discard block
 block discarded – undo
208 222
             Throw new \Exception($e->getMessage());
209 223
         }
210 224
 
211
-        if (!isset(static::$primary_key)) throw new \Exception('Primary key don\'t set');
225
+        if (!isset(static::$primary_key)) {
226
+         throw new \Exception('Primary key don\'t set');
227
+        }
212 228
 
213
-        if (!is_numeric($this->{static::$primary_key})) throw new \Exception('Primary key value don\'t is valid');
229
+        if (!is_numeric($this->{static::$primary_key})) {
230
+         throw new \Exception('Primary key value don\'t is valid');
231
+        }
214 232
 
215 233
         $sql = ' DELETE FROM ' . static::$table_name;
216 234
         $sql .= ' WHERE ' . static::$primary_key . ' = ? ';
217 235
 
218 236
         $instance = self::$_instance;
219 237
 
220
-        if (is_callable($this->triggerBefore)) ($this->triggerBefore)();;
238
+        if (is_callable($this->triggerBefore)) {
239
+         ($this->triggerBefore)();
240
+        }
241
+        ;
221 242
 
222 243
         $start = microtime(true);
223 244
 
@@ -228,10 +249,15 @@  discard block
 block discarded – undo
228 249
 
229 250
         $instance->Connection->setPerformedQuery($insert->queryString, round(($end - $start), 5));
230 251
 
231
-        if (is_callable($this->triggerAfter)) ($this->triggerAfter)();
252
+        if (is_callable($this->triggerAfter)) {
253
+         ($this->triggerAfter)();
254
+        }
232 255
 
233
-        if ($insert->rowCount() > 0) return true;
234
-        else return false;
256
+        if ($insert->rowCount() > 0) {
257
+         return true;
258
+        } else {
259
+         return false;
260
+        }
235 261
     }
236 262
 
237 263
     /**
@@ -249,7 +275,9 @@  discard block
 block discarded – undo
249 275
      */
250 276
     public static function all()
251 277
     {
252
-        if (!isset(static::$table_name)) throw new \Exception('Don\'t set table name in model.');
278
+        if (!isset(static::$table_name)) {
279
+         throw new \Exception('Don\'t set table name in model.');
280
+        }
253 281
 
254 282
         $currentTable = static::$table_name;
255 283
 
@@ -286,8 +314,12 @@  discard block
 block discarded – undo
286 314
     {
287 315
         self::instance();
288 316
 
289
-        if (!is_string($procedureName)) throw new \Exception("Procedure name is invalid.");
290
-        if (!is_array($param)) throw new \Exception("Tipo de parâmetros inválidos.");
317
+        if (!is_string($procedureName)) {
318
+         throw new \Exception("Procedure name is invalid.");
319
+        }
320
+        if (!is_array($param)) {
321
+         throw new \Exception("Tipo de parâmetros inválidos.");
322
+        }
291 323
 
292 324
         $currentTable = static::$table_name;
293 325
 
@@ -339,7 +371,9 @@  discard block
 block discarded – undo
339 371
         self::$_instance->_data = [];
340 372
         self::$_instance->_newData = [];
341 373
 
342
-        if (!is_array($attributes)) throw new \Exception("Invalid parameter type.");
374
+        if (!is_array($attributes)) {
375
+         throw new \Exception("Invalid parameter type.");
376
+        }
343 377
 
344 378
         $repeat = substr(str_repeat(' ?, ', count($attributes)), 0, -2);
345 379
 
@@ -356,7 +390,9 @@  discard block
 block discarded – undo
356 390
             Throw new \Exception($e->getMessage());
357 391
         }
358 392
 
359
-        if (is_callable(self::$_instance->triggerBefore)) self::$_instance->triggerBefore();
393
+        if (is_callable(self::$_instance->triggerBefore)) {
394
+         self::$_instance->triggerBefore();
395
+        }
360 396
 
361 397
         $start = microtime(true);
362 398
 
@@ -367,7 +403,9 @@  discard block
 block discarded – undo
367 403
 
368 404
         $instance->Connection->setPerformedQuery($insert->queryString, round(($end - $start), 5));
369 405
 
370
-        if (is_callable(self::$_instance->triggerAfter)) self::$_instance->triggerAfter();
406
+        if (is_callable(self::$_instance->triggerAfter)) {
407
+         self::$_instance->triggerAfter();
408
+        }
371 409
 
372 410
         $instance->_data = $attributes;
373 411
         $instance->_data[static::$primary_key] = $instance->Connection->getConnection()->lastInsertId();
@@ -395,13 +433,17 @@  discard block
 block discarded – undo
395 433
             throw new \Exception($e->getMessage());
396 434
         }
397 435
 
398
-        if (!is_array($parameters) and !is_numeric($parameters)) throw new \Exception('Invalid parameter type on model ' . get_called_class() . '.');
436
+        if (!is_array($parameters) and !is_numeric($parameters)) {
437
+         throw new \Exception('Invalid parameter type on model ' . get_called_class() . '.');
438
+        }
399 439
 
400 440
         self::$_instance->_current_custom_query[] = 'SELECT * FROM ' . static::$table_name . ' ';
401 441
 
402 442
         switch ($parameters) {
403 443
             case is_numeric($parameters):
404
-                if (!isset(static::$primary_key)) throw new \Exception("Invalid parameter type.");
444
+                if (!isset(static::$primary_key)) {
445
+                 throw new \Exception("Invalid parameter type.");
446
+                }
405 447
 
406 448
                 self::$_instance->_current_custom_query_values[] = $parameters;
407 449
                 self::$_instance->_current_custom_query[] = ' WHERE ' . static::$primary_key . ' = ?';
@@ -435,11 +477,15 @@  discard block
 block discarded – undo
435 477
             throw new \Exception($e->getMessage());
436 478
         }
437 479
 
438
-        if (!is_string($colunm)) throw new \Exception("Invalid parameter type.");
480
+        if (!is_string($colunm)) {
481
+         throw new \Exception("Invalid parameter type.");
482
+        }
439 483
 
440 484
         self::$_instance->_current_custom_query[] = "SELECT $colunm FROM " . static::$table_name . ' ';
441 485
 
442
-        if (!isset(static::$primary_key)) throw new \Exception("Invalid parameter type.");
486
+        if (!isset(static::$primary_key)) {
487
+         throw new \Exception("Invalid parameter type.");
488
+        }
443 489
 
444 490
         return self::$_instance;
445 491
     }
@@ -508,7 +554,9 @@  discard block
 block discarded – undo
508 554
             throw new \Exception($e->getMessage());
509 555
         }
510 556
 
511
-        if (!is_array($param)) throw new \Exception('Tipo de parâmetro inválido.');
557
+        if (!is_array($param)) {
558
+         throw new \Exception('Tipo de parâmetro inválido.');
559
+        }
512 560
 
513 561
         $start = microtime(true);
514 562
 
@@ -553,7 +601,9 @@  discard block
 block discarded – undo
553 601
             throw new \Exception($e->getMessage());
554 602
         }
555 603
 
556
-        if (!is_array($param)) throw new \Exception('Invalid parameter type.');
604
+        if (!is_array($param)) {
605
+         throw new \Exception('Invalid parameter type.');
606
+        }
557 607
 
558 608
         self::$_instance->_current_custom_query_values = $param;
559 609
 
@@ -592,7 +642,9 @@  discard block
 block discarded – undo
592 642
      */
593 643
     final protected function setTriggerAfter($closure = null)
594 644
     {
595
-        if (!is_callable($closure)) throw new Exception('The parameter don\'t is an closure.');
645
+        if (!is_callable($closure)) {
646
+         throw new Exception('The parameter don\'t is an closure.');
647
+        }
596 648
 
597 649
         $this->triggerAfter = $closure;
598 650
 
@@ -607,7 +659,9 @@  discard block
 block discarded – undo
607 659
      */
608 660
     final protected function setTriggerBefore($closure = null)
609 661
     {
610
-        if (!is_callable($closure)) throw new Exception('The parameter don\'t is an closure.');
662
+        if (!is_callable($closure)) {
663
+         throw new Exception('The parameter don\'t is an closure.');
664
+        }
611 665
 
612 666
         $this->triggerBefore = $closure;
613 667
 
@@ -621,7 +675,9 @@  discard block
 block discarded – undo
621 675
      */
622 676
     final protected function changeSchema($schema)
623 677
     {
624
-        if (!is_string($schema)) throw new \Exception('The parameter don\'t is an String.');
678
+        if (!is_string($schema)) {
679
+         throw new \Exception('The parameter don\'t is an String.');
680
+        }
625 681
 
626 682
         $this->Connection->changeSchema($schema);
627 683
         return $this;
@@ -659,6 +715,8 @@  discard block
 block discarded – undo
659 715
 
660 716
     final private function verifyConnection()
661 717
     {
662
-        if (is_null($this->Connection->getCurrentConnectionString())) throw new \Exception('Not set connection.');
718
+        if (is_null($this->Connection->getCurrentConnectionString())) {
719
+         throw new \Exception('Not set connection.');
720
+        }
663 721
     }
664 722
 }
665 723
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Query.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -202,7 +202,7 @@
 block discarded – undo
202 202
         if (substr_count($last, 'ORDER BY') > 0) {
203 203
             $sql .= isset($this->_group) ? $this->_group : '';
204 204
             $sql .= $last;
205
-        } else {
205
+        }else {
206 206
             $sql .= $last;
207 207
             $sql .= isset($this->_group) ? $this->_group : '';
208 208
         }
Please login to merge, or discard this patch.
Braces   +36 added lines, -12 removed lines patch added patch discarded remove patch
@@ -48,8 +48,12 @@  discard block
 block discarded – undo
48 48
      */
49 49
     final public function where($parameter = null, $value = null)
50 50
     {
51
-        if (!is_string($parameter)) throw new \Exception('Invalid parameter type.');
52
-        if (!isset($value)) throw new \Exception('This value not set.');
51
+        if (!is_string($parameter)) {
52
+         throw new \Exception('Invalid parameter type.');
53
+        }
54
+        if (!isset($value)) {
55
+         throw new \Exception('This value not set.');
56
+        }
53 57
 
54 58
         $this->_current_custom_query[] = " WHERE $parameter = ? ";
55 59
         $this->_current_custom_query_values[] = $value;
@@ -66,8 +70,12 @@  discard block
 block discarded – undo
66 70
      */
67 71
     final public function and ($parameter = null, $value = null)
68 72
     {
69
-        if (!is_string($parameter)) throw new \Exception('Invalid parameter type.');
70
-        if (!isset($value)) throw new \Exception('This value not set.');
73
+        if (!is_string($parameter)) {
74
+         throw new \Exception('Invalid parameter type.');
75
+        }
76
+        if (!isset($value)) {
77
+         throw new \Exception('This value not set.');
78
+        }
71 79
 
72 80
         $this->_current_custom_query[] = " AND $parameter = ? ";
73 81
         $this->_current_custom_query_values[] = $value;
@@ -84,8 +92,12 @@  discard block
 block discarded – undo
84 92
      */
85 93
     final public function or ($parameter = null, $value = null)
86 94
     {
87
-        if (!is_string($parameter)) throw new \Exception('Invalid parameter type.');
88
-        if (!isset($value)) throw new \Exception('This value not set.');
95
+        if (!is_string($parameter)) {
96
+         throw new \Exception('Invalid parameter type.');
97
+        }
98
+        if (!isset($value)) {
99
+         throw new \Exception('This value not set.');
100
+        }
89 101
 
90 102
         $this->_current_custom_query[] = " OR $parameter = ? ";
91 103
         $this->_current_custom_query_values[] = $value;
@@ -102,10 +114,18 @@  discard block
 block discarded – undo
102 114
      */
103 115
     final public function orderBy($parameter = null, $value = null)
104 116
     {
105
-        if (!is_string($parameter)) throw new \Exception('Invalid parameter type.');
106
-        if (!isset($value)) throw new \Exception('This value not set.');
107
-        if (!is_string($value)) throw new \Exception('Don\'t accepted this type on value.');
108
-        if ($value != 'ASC' AND $value != 'DESC') throw new \Exception('This value not found.');
117
+        if (!is_string($parameter)) {
118
+         throw new \Exception('Invalid parameter type.');
119
+        }
120
+        if (!isset($value)) {
121
+         throw new \Exception('This value not set.');
122
+        }
123
+        if (!is_string($value)) {
124
+         throw new \Exception('Don\'t accepted this type on value.');
125
+        }
126
+        if ($value != 'ASC' AND $value != 'DESC') {
127
+         throw new \Exception('This value not found.');
128
+        }
109 129
 
110 130
         $this->_current_custom_query[] = " ORDER BY $parameter $value";
111 131
 
@@ -119,7 +139,9 @@  discard block
 block discarded – undo
119 139
      */
120 140
     final public function custom($partialQuery)
121 141
     {
122
-        if (!is_string($partialQuery)) throw new \Exception('Invalid parameter type.');
142
+        if (!is_string($partialQuery)) {
143
+         throw new \Exception('Invalid parameter type.');
144
+        }
123 145
 
124 146
         $this->_current_custom_query[] = $partialQuery;
125 147
 
@@ -178,7 +200,9 @@  discard block
 block discarded – undo
178 200
      */
179 201
     final public function groupBy($colunm)
180 202
     {
181
-        if (!is_string($colunm)) throw new \Exception('The colunm isn\'t an string.');
203
+        if (!is_string($colunm)) {
204
+         throw new \Exception('The colunm isn\'t an string.');
205
+        }
182 206
 
183 207
         $this->_group = " GROUP BY $colunm ";
184 208
 
Please login to merge, or discard this patch.
lib/Error.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
     {
24 24
         $instance = self::instance();
25 25
 
26
-        if ($instance->burst) $instance->burst($message, $code, $type);
26
+        if ($instance->burst) {
27
+         $instance->burst($message, $code, $type);
28
+        }
27 29
 
28 30
         $errors['message'] = $message;
29 31
         $errors['code'] = $code;
@@ -36,7 +38,9 @@  discard block
 block discarded – undo
36 38
 
37 39
     public static function instance()
38 40
     {
39
-        if (!self::$_instance) self::$_instance = new self();
41
+        if (!self::$_instance) {
42
+         self::$_instance = new self();
43
+        }
40 44
         return self::$_instance;
41 45
     }
42 46
 
Please login to merge, or discard this patch.
lib/ConnectionManager.php 2 patches
Spacing   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -100,8 +100,7 @@  discard block
 block discarded – undo
100 100
             $default = $this->Config->getDefault();
101 101
 
102 102
             $name = is_null($default) ?
103
-                @end(array_keys($configs)) :
104
-                $this->Config->getDefault();
103
+                @end(array_keys($configs)) : $this->Config->getDefault();
105 104
 
106 105
             self::open($name);
107 106
         }
@@ -132,7 +131,7 @@  discard block
 block discarded – undo
132 131
                 } catch (\Exception $e) {
133 132
                     throw $e;
134 133
                 }
135
-            } else {
134
+            }else {
136 135
 
137 136
                 throw new \Exception("This connection isn't actived.");
138 137
             }
@@ -178,7 +177,7 @@  discard block
 block discarded – undo
178 177
     {
179 178
         if (array_key_exists($connectionName, $this->connections)) {
180 179
             return true;
181
-        } else {
180
+        }else {
182 181
             return false;
183 182
         }
184 183
     }
@@ -201,7 +200,7 @@  discard block
 block discarded – undo
201 200
     {
202 201
         if (array_key_exists($connectionName, $this->Config->getConfigs())) {
203 202
             return true;
204
-        } else {
203
+        }else {
205 204
             return false;
206 205
         }
207 206
     }
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,9 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public static function initialize($config = null)
43 43
     {
44
-        if (!self::$_instance) self::$_instance = new ConnectionManager();
44
+        if (!self::$_instance) {
45
+         self::$_instance = new ConnectionManager();
46
+        }
45 47
 
46 48
         if (is_callable($config)) {
47 49
 
@@ -63,9 +65,15 @@  discard block
 block discarded – undo
63 65
     {
64 66
         $instance = self::$_instance;
65 67
 
66
-        if (!is_string($connectionName)) throw new \Exception("Invalid connection name.");
67
-        if (!$instance->hasConnection($connectionName)) throw new \Exception("The connection name $connectionName is not set.");
68
-        if ($instance->hasOpen($connectionName)) throw new \Exception('This connection is actived.');
68
+        if (!is_string($connectionName)) {
69
+         throw new \Exception("Invalid connection name.");
70
+        }
71
+        if (!$instance->hasConnection($connectionName)) {
72
+         throw new \Exception("The connection name $connectionName is not set.");
73
+        }
74
+        if ($instance->hasOpen($connectionName)) {
75
+         throw new \Exception('This connection is actived.');
76
+        }
69 77
 
70 78
         $instance->_currentConnectionName = $connectionName;
71 79
 
@@ -95,7 +103,9 @@  discard block
 block discarded – undo
95 103
         if (empty($this->currentConnection)) {
96 104
             $configs = $this->Config->getConfigs();
97 105
 
98
-            if (count($configs) == 0) throw new \Exception('Not have connection');
106
+            if (count($configs) == 0) {
107
+             throw new \Exception('Not have connection');
108
+            }
99 109
 
100 110
             $default = $this->Config->getDefault();
101 111
 
@@ -121,9 +131,13 @@  discard block
 block discarded – undo
121 131
     {
122 132
         $instance = self::initialize();
123 133
 
124
-        if (!is_string($connectionName)) throw new \Exception("Invalid connection name.");
134
+        if (!is_string($connectionName)) {
135
+         throw new \Exception("Invalid connection name.");
136
+        }
125 137
 
126
-        if (!$instance->hasConnection($connectionName)) throw new \Exception("The connection name $connectionName is not set.");
138
+        if (!$instance->hasConnection($connectionName)) {
139
+         throw new \Exception("The connection name $connectionName is not set.");
140
+        }
127 141
 
128 142
         if (!$instance->hasOpen($connectionName)) {
129 143
             if ($open) {
@@ -154,7 +168,9 @@  discard block
 block discarded – undo
154 168
      */
155 169
     public function getAllActive()
156 170
     {
157
-        if (!$this->hasInstance()) throw new \Exception('This instance isnt\'t initialized');
171
+        if (!$this->hasInstance()) {
172
+         throw new \Exception('This instance isnt\'t initialized');
173
+        }
158 174
 
159 175
         return $this->connections;
160 176
     }
Please login to merge, or discard this patch.
lib/support/Transaction.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         if (!is_callable($closure)) {
39 39
             throw new \Exception("Transaction must have a callable as parameter.");
40 40
 
41
-        } else {
41
+        }else {
42 42
             $connection = $this->getConnection();
43 43
 
44 44
             try {
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
                 if ($this->results === false) {
50 50
                     $connection->rollbackTransaction();
51
-                } else {
51
+                }else {
52 52
                     $connection->commitTransaction();
53 53
                 }
54 54
 
Please login to merge, or discard this patch.