@@ -96,7 +96,9 @@ discard block |
||
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 |
||
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; |
@@ -134,7 +134,7 @@ |
||
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 |
@@ -63,15 +63,27 @@ |
||
63 | 63 | { |
64 | 64 | |
65 | 65 | #Begin: Verify if all parameters send is valid. |
66 | - if (!is_string($driver) || !in_array($driver, self::DRIVERS)) throw new \Exception("The driver $driver don't supported."); |
|
67 | - if (!is_string($username) || empty($username)) throw new \Exception("Invalid username."); |
|
68 | - if (!is_string($password) || empty($password)) throw new \Exception("Invalid password."); |
|
69 | - if (!is_string($host) || empty($host)) throw new \Exception("Invalid host."); |
|
70 | - if (!is_string($database) || empty($database)) throw new \Exception("Invalid database name."); |
|
66 | + if (!is_string($driver) || !in_array($driver, self::DRIVERS)) { |
|
67 | + throw new \Exception("The driver $driver don't supported."); |
|
68 | + } |
|
69 | + if (!is_string($username) || empty($username)) { |
|
70 | + throw new \Exception("Invalid username."); |
|
71 | + } |
|
72 | + if (!is_string($password) || empty($password)) { |
|
73 | + throw new \Exception("Invalid password."); |
|
74 | + } |
|
75 | + if (!is_string($host) || empty($host)) { |
|
76 | + throw new \Exception("Invalid host."); |
|
77 | + } |
|
78 | + if (!is_string($database) || empty($database)) { |
|
79 | + throw new \Exception("Invalid database name."); |
|
80 | + } |
|
71 | 81 | $this->validatesConnectionName($connectionName); |
72 | 82 | |
73 | 83 | $port = is_null($port) ? '' : (int)$port; |
74 | - if (!is_null($port) && !is_int($port)) throw new \Exception("Invalid port format."); |
|
84 | + if (!is_null($port) && !is_int($port)) { |
|
85 | + throw new \Exception("Invalid port format."); |
|
86 | + } |
|
75 | 87 | |
76 | 88 | #Constructor of the connection string |
77 | 89 | $this->_connectionString[$connectionName] = "$driver:host=$host;dbname=$database;port=$port;"; |
@@ -135,8 +135,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -55,7 +55,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | |
@@ -338,7 +370,9 @@ discard block |
||
338 | 370 | |
339 | 371 | self::$_instance->_data = []; |
340 | 372 | |
341 | - if (!is_array($attributes)) throw new \Exception("Invalid parameter type."); |
|
373 | + if (!is_array($attributes)) { |
|
374 | + throw new \Exception("Invalid parameter type."); |
|
375 | + } |
|
342 | 376 | |
343 | 377 | $repeat = substr(str_repeat(' ?, ', count($attributes)), 0, -2); |
344 | 378 | |
@@ -355,7 +389,9 @@ discard block |
||
355 | 389 | Throw new \Exception($e->getMessage()); |
356 | 390 | } |
357 | 391 | |
358 | - if (is_callable(self::$_instance->triggerBefore)) self::$_instance->triggerBefore(); |
|
392 | + if (is_callable(self::$_instance->triggerBefore)) { |
|
393 | + self::$_instance->triggerBefore(); |
|
394 | + } |
|
359 | 395 | |
360 | 396 | $start = microtime(true); |
361 | 397 | |
@@ -366,7 +402,9 @@ discard block |
||
366 | 402 | |
367 | 403 | $instance->Connection->setPerformedQuery($insert->queryString, round(($end - $start), 5)); |
368 | 404 | |
369 | - if (is_callable(self::$_instance->triggerAfter)) self::$_instance->triggerAfter(); |
|
405 | + if (is_callable(self::$_instance->triggerAfter)) { |
|
406 | + self::$_instance->triggerAfter(); |
|
407 | + } |
|
370 | 408 | |
371 | 409 | $instance->_data = $attributes; |
372 | 410 | $instance->_data[static::$primary_key] = $instance->Connection->getConnection()->lastInsertId(); |
@@ -394,13 +432,17 @@ discard block |
||
394 | 432 | throw new \Exception($e->getMessage()); |
395 | 433 | } |
396 | 434 | |
397 | - if (!is_array($parameters) and !is_numeric($parameters)) throw new \Exception('Invalid parameter type on model ' . get_called_class() . '.'); |
|
435 | + if (!is_array($parameters) and !is_numeric($parameters)) { |
|
436 | + throw new \Exception('Invalid parameter type on model ' . get_called_class() . '.'); |
|
437 | + } |
|
398 | 438 | |
399 | 439 | self::$_instance->_current_custom_query[] = 'SELECT * FROM ' . static::$table_name . ' '; |
400 | 440 | |
401 | 441 | switch ($parameters) { |
402 | 442 | case is_numeric($parameters): |
403 | - if (!isset(static::$primary_key)) throw new \Exception("Invalid parameter type."); |
|
443 | + if (!isset(static::$primary_key)) { |
|
444 | + throw new \Exception("Invalid parameter type."); |
|
445 | + } |
|
404 | 446 | |
405 | 447 | self::$_instance->_current_custom_query_values[] = $parameters; |
406 | 448 | self::$_instance->_current_custom_query[] = ' WHERE ' . static::$primary_key . ' = ?'; |
@@ -434,11 +476,15 @@ discard block |
||
434 | 476 | throw new \Exception($e->getMessage()); |
435 | 477 | } |
436 | 478 | |
437 | - if (!is_string($colunm)) throw new \Exception("Invalid parameter type."); |
|
479 | + if (!is_string($colunm)) { |
|
480 | + throw new \Exception("Invalid parameter type."); |
|
481 | + } |
|
438 | 482 | |
439 | 483 | self::$_instance->_current_custom_query[] = "SELECT $colunm FROM " . static::$table_name . ' '; |
440 | 484 | |
441 | - if (!isset(static::$primary_key)) throw new \Exception("Invalid parameter type."); |
|
485 | + if (!isset(static::$primary_key)) { |
|
486 | + throw new \Exception("Invalid parameter type."); |
|
487 | + } |
|
442 | 488 | |
443 | 489 | return self::$_instance; |
444 | 490 | } |
@@ -507,7 +553,9 @@ discard block |
||
507 | 553 | throw new \Exception($e->getMessage()); |
508 | 554 | } |
509 | 555 | |
510 | - if (!is_array($param)) throw new \Exception('Tipo de parâmetro inválido.'); |
|
556 | + if (!is_array($param)) { |
|
557 | + throw new \Exception('Tipo de parâmetro inválido.'); |
|
558 | + } |
|
511 | 559 | |
512 | 560 | $start = microtime(true); |
513 | 561 | |
@@ -552,7 +600,9 @@ discard block |
||
552 | 600 | throw new \Exception($e->getMessage()); |
553 | 601 | } |
554 | 602 | |
555 | - if (!is_array($param)) throw new \Exception('Invalid parameter type.'); |
|
603 | + if (!is_array($param)) { |
|
604 | + throw new \Exception('Invalid parameter type.'); |
|
605 | + } |
|
556 | 606 | |
557 | 607 | self::$_instance->_current_custom_query_values = $param; |
558 | 608 | |
@@ -591,7 +641,9 @@ discard block |
||
591 | 641 | */ |
592 | 642 | final protected function setTriggerAfter($closure = null) |
593 | 643 | { |
594 | - if (!is_callable($closure)) throw new Exception('The parameter don\'t is an closure.'); |
|
644 | + if (!is_callable($closure)) { |
|
645 | + throw new Exception('The parameter don\'t is an closure.'); |
|
646 | + } |
|
595 | 647 | |
596 | 648 | $this->triggerAfter = $closure; |
597 | 649 | |
@@ -606,7 +658,9 @@ discard block |
||
606 | 658 | */ |
607 | 659 | final protected function setTriggerBefore($closure = null) |
608 | 660 | { |
609 | - if (!is_callable($closure)) throw new Exception('The parameter don\'t is an closure.'); |
|
661 | + if (!is_callable($closure)) { |
|
662 | + throw new Exception('The parameter don\'t is an closure.'); |
|
663 | + } |
|
610 | 664 | |
611 | 665 | $this->triggerBefore = $closure; |
612 | 666 | |
@@ -620,7 +674,9 @@ discard block |
||
620 | 674 | */ |
621 | 675 | final protected function changeSchema($schema) |
622 | 676 | { |
623 | - if (!is_string($schema)) throw new \Exception('The parameter don\'t is an String.'); |
|
677 | + if (!is_string($schema)) { |
|
678 | + throw new \Exception('The parameter don\'t is an String.'); |
|
679 | + } |
|
624 | 680 | |
625 | 681 | $this->Connection->changeSchema($schema); |
626 | 682 | return $this; |
@@ -658,6 +714,8 @@ discard block |
||
658 | 714 | |
659 | 715 | final private function verifyConnection() |
660 | 716 | { |
661 | - if (is_null($this->Connection->getCurrentConnectionString())) throw new \Exception('Not set connection.'); |
|
717 | + if (is_null($this->Connection->getCurrentConnectionString())) { |
|
718 | + throw new \Exception('Not set connection.'); |
|
719 | + } |
|
662 | 720 | } |
663 | 721 | } |
664 | 722 | \ No newline at end of file |
@@ -202,7 +202,7 @@ |
||
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 | } |
@@ -48,8 +48,12 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -23,7 +23,9 @@ discard block |
||
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 |
||
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 |
@@ -100,8 +100,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -41,7 +41,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -79,7 +79,6 @@ |
||
79 | 79 | /** |
80 | 80 | * 6. if needed change the connection using the method change |
81 | 81 | * - $connectionManager::change('local'); |
82 | - |
|
83 | 82 | * @return Connection |
84 | 83 | */ |
85 | 84 | $connectionManager::change('local'); |
@@ -54,7 +54,7 @@ |
||
54 | 54 | * @param \Closure $connection |
55 | 55 | * @return \ConnectionManager |
56 | 56 | */ |
57 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
57 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
58 | 58 | /** |
59 | 59 | * 4. Add the configurations using the method addConfig, accepts various configurations |
60 | 60 | * Arguments: |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param \Closure $connection |
33 | 33 | * @return \ConnectionManager |
34 | 34 | */ |
35 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
35 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
36 | 36 | /** |
37 | 37 | * Add the configurations using the method addConfig, accepts various configurations |
38 | 38 | * Arguments: |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | */ |
55 | 55 | $usage = UsageModel::procedure('criar_usuario', ['Teste procedure apelido']); |
56 | 56 | var_dump($usage); |
57 | - if($usage){ |
|
57 | + if ($usage) { |
|
58 | 58 | var_dump($usage); |
59 | - }else{ |
|
59 | + }else { |
|
60 | 60 | echo 'The procedure not executed.'; |
61 | 61 | } |
62 | 62 |
@@ -56,7 +56,7 @@ |
||
56 | 56 | var_dump($usage); |
57 | 57 | if($usage){ |
58 | 58 | var_dump($usage); |
59 | - }else{ |
|
59 | + } else{ |
|
60 | 60 | echo 'The procedure not executed.'; |
61 | 61 | } |
62 | 62 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param \Closure $connection |
40 | 40 | * @return \ConnectionManager |
41 | 41 | */ |
42 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
42 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
43 | 43 | /** |
44 | 44 | * Add the configurations using the method addConfig, accepts various configurations |
45 | 45 | * Arguments: |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | */ |
74 | 74 | $result = $usage->save(); |
75 | 75 | |
76 | - if($result){ |
|
76 | + if ($result) { |
|
77 | 77 | echo 'Data Edited.'; |
78 | - }else{ |
|
78 | + }else { |
|
79 | 79 | echo 'Haven\'t data for this ID.'; |
80 | 80 | } |
81 | 81 |
@@ -75,7 +75,7 @@ |
||
75 | 75 | |
76 | 76 | if($result){ |
77 | 77 | echo 'Data Edited.'; |
78 | - }else{ |
|
78 | + } else{ |
|
79 | 79 | echo 'Haven\'t data for this ID.'; |
80 | 80 | } |
81 | 81 |