@@ -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 |
@@ -38,7 +38,7 @@ discard block |
||
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 |
||
48 | 48 | |
49 | 49 | if ($this->results === false) { |
50 | 50 | $connection->rollbackTransaction(); |
51 | - } else { |
|
51 | + }else { |
|
52 | 52 | $connection->commitTransaction(); |
53 | 53 | } |
54 | 54 |
@@ -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) || empty($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) || empty($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) ? $this->Config->getConfigs() : null; |
97 | 105 | |
98 | - if (count($configs) == 0) throw new \Exception('No connections are available.'); |
|
106 | + if (count($configs) == 0) { |
|
107 | + throw new \Exception('No connections are available.'); |
|
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 | } |
@@ -101,8 +101,7 @@ discard block |
||
101 | 101 | $default = $this->Config->getDefault(); |
102 | 102 | |
103 | 103 | $name = is_null($default) ? |
104 | - @end(array_keys($configs ?: [])) : |
|
105 | - $default; |
|
104 | + @end(array_keys($configs ?: [])) : $default; |
|
106 | 105 | |
107 | 106 | $this->open($name); |
108 | 107 | } |
@@ -133,7 +132,7 @@ discard block |
||
133 | 132 | } catch (\Exception $e) { |
134 | 133 | throw $e; |
135 | 134 | } |
136 | - } else { |
|
135 | + }else { |
|
137 | 136 | |
138 | 137 | throw new \Exception("This connection isn't actived."); |
139 | 138 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | 'password' => $this->_password[$connectionName], |
150 | 150 | 'charset' => $this->_charset[$connectionName], |
151 | 151 | 'schema' => $this->_schema[$connectionName]]; |
152 | - } else { |
|
152 | + }else { |
|
153 | 153 | throw new \Exception("The connection name $connectionName is not set."); |
154 | 154 | } |
155 | 155 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | $connectionSettings = (object)$connectionSettings; |
185 | 185 | |
186 | - $this->_connectionString[$connectionName] = $this->_driver[$connectionName].":host=$connectionSettings->host;dbname=$connectionSettings->database;port=$connectionSettings->port;"; |
|
186 | + $this->_connectionString[$connectionName] = $this->_driver[$connectionName] . ":host=$connectionSettings->host;dbname=$connectionSettings->database;port=$connectionSettings->port;"; |
|
187 | 187 | |
188 | 188 | return $this; |
189 | 189 | } |
@@ -79,15 +79,27 @@ discard block |
||
79 | 79 | $defaultSchema = null) |
80 | 80 | { |
81 | 81 | #Begin: Verify if all parameters send is valid. |
82 | - if (!is_string($driver) || !in_array($driver, self::DRIVERS)) throw new \Exception("The driver $driver don't supported."); |
|
83 | - if (!is_string($username) || empty($username)) throw new \Exception("Invalid username."); |
|
84 | - if (!is_string($password) || empty($password)) throw new \Exception("Invalid password."); |
|
85 | - if (!is_string($host) || empty($host)) throw new \Exception("Invalid host."); |
|
86 | - if (!is_string($database) || empty($database)) throw new \Exception("Invalid database name."); |
|
82 | + if (!is_string($driver) || !in_array($driver, self::DRIVERS)) { |
|
83 | + throw new \Exception("The driver $driver don't supported."); |
|
84 | + } |
|
85 | + if (!is_string($username) || empty($username)) { |
|
86 | + throw new \Exception("Invalid username."); |
|
87 | + } |
|
88 | + if (!is_string($password) || empty($password)) { |
|
89 | + throw new \Exception("Invalid password."); |
|
90 | + } |
|
91 | + if (!is_string($host) || empty($host)) { |
|
92 | + throw new \Exception("Invalid host."); |
|
93 | + } |
|
94 | + if (!is_string($database) || empty($database)) { |
|
95 | + throw new \Exception("Invalid database name."); |
|
96 | + } |
|
87 | 97 | $this->validatesConnectionName($connectionName); |
88 | 98 | |
89 | 99 | $port = is_null($port) ? '' : (int)$port; |
90 | - if (!is_null($port) && !is_int($port)) throw new \Exception("Invalid port format."); |
|
100 | + if (!is_null($port) && !is_int($port)) { |
|
101 | + throw new \Exception("Invalid port format."); |
|
102 | + } |
|
91 | 103 | #Constructor of the connection string |
92 | 104 | $this->_connectionString[$connectionName] = "$driver:host=$host;dbname=$database;port=$port;"; |
93 | 105 | $this->_username[$connectionName] = $username; |
@@ -176,8 +188,12 @@ discard block |
||
176 | 188 | */ |
177 | 189 | public function setSettings($connectionName, $connectionSettings) |
178 | 190 | { |
179 | - if (!is_array($connectionSettings)) throw new \Exception('Invalid format connectionSettings'); |
|
180 | - if (empty($this->_driver[$connectionName])) throw new \Exception('Driver not set.'); |
|
191 | + if (!is_array($connectionSettings)) { |
|
192 | + throw new \Exception('Invalid format connectionSettings'); |
|
193 | + } |
|
194 | + if (empty($this->_driver[$connectionName])) { |
|
195 | + throw new \Exception('Driver not set.'); |
|
196 | + } |
|
181 | 197 | |
182 | 198 | $this->validatesConnectionName($connectionName); |
183 | 199 |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | $this->Result = new Result(); |
76 | 76 | |
77 | - if($this->Result && !$this->Result->getResults()) { |
|
77 | + if ($this->Result && !$this->Result->getResults()) { |
|
78 | 78 | $clone = clone $this; |
79 | 79 | $this->Result->setResults($clone); |
80 | 80 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $this->_newData[] = $this->{$key}; |
189 | 189 | |
190 | 190 | $update = true; |
191 | - } else { |
|
191 | + }else { |
|
192 | 192 | $logger = [ |
193 | 193 | 'function' => 'Save', |
194 | 194 | 'next' => $this->_data, |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $insert = $this->Connection->getConnection()->prepare($sql); |
213 | 213 | $this->burnError($insert); |
214 | 214 | |
215 | - $this->_newData = array_map(function ($data) { |
|
215 | + $this->_newData = array_map(function($data) { |
|
216 | 216 | if (is_bool($data) and $data === false) $data = 0; |
217 | 217 | |
218 | 218 | return $data; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | |
288 | 288 | $instance = self::$_instance; |
289 | 289 | |
290 | - if (is_callable($this->triggerBefore)) ($this->triggerBefore)();; |
|
290 | + if (is_callable($this->triggerBefore)) ($this->triggerBefore)(); ; |
|
291 | 291 | |
292 | 292 | $start = microtime(true); |
293 | 293 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | |
311 | 311 | return true; |
312 | 312 | } |
313 | - else{ return false; }; |
|
313 | + else { return false; }; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | |
456 | 456 | $done = $instance->done(); |
457 | 457 | |
458 | - if(count($done) > 0) { |
|
458 | + if (count($done) > 0) { |
|
459 | 459 | $done = $done[0]; |
460 | 460 | |
461 | 461 | $clone = clone $done; |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | |
558 | 558 | if ($match) { |
559 | 559 | $this->_data = $objetos = $consulta->fetchAll(\PDO::FETCH_CLASS, get_called_class()); |
560 | - } else { |
|
560 | + }else { |
|
561 | 561 | $objetos = $consulta->rowCount(); |
562 | 562 | } |
563 | 563 |
@@ -68,7 +68,9 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | if (!is_null($array)) { |
71 | - if (!is_array($array)) throw new \InvalidArgumentException('Accept only array from object'); |
|
71 | + if (!is_array($array)) { |
|
72 | + throw new \InvalidArgumentException('Accept only array from object'); |
|
73 | + } |
|
72 | 74 | |
73 | 75 | $this->_data = $array; |
74 | 76 | $this->_newData = $array; |
@@ -102,9 +104,13 @@ discard block |
||
102 | 104 | */ |
103 | 105 | public function __get($name) |
104 | 106 | { |
105 | - if (strtolower($name) == 'errors') return Error::instance(); |
|
107 | + if (strtolower($name) == 'errors') { |
|
108 | + return Error::instance(); |
|
109 | + } |
|
106 | 110 | |
107 | - if (!key_exists($name, $this->_data)) throw new \Exception("The attribute $name not found."); |
|
111 | + if (!key_exists($name, $this->_data)) { |
|
112 | + throw new \Exception("The attribute $name not found."); |
|
113 | + } |
|
108 | 114 | |
109 | 115 | return $this->_data[$name]; |
110 | 116 | } |
@@ -208,14 +214,18 @@ discard block |
||
208 | 214 | } |
209 | 215 | |
210 | 216 | |
211 | - if (is_callable($this->triggerBefore)) ($this->triggerBefore)(); |
|
217 | + if (is_callable($this->triggerBefore)) { |
|
218 | + ($this->triggerBefore)(); |
|
219 | + } |
|
212 | 220 | |
213 | 221 | $start = microtime(true); |
214 | 222 | $insert = $this->Connection->getConnection()->prepare($sql); |
215 | 223 | $this->burnError($insert); |
216 | 224 | |
217 | 225 | $this->_newData = array_map(function ($data) { |
218 | - if (is_bool($data) and $data === false) $data = 0; |
|
226 | + if (is_bool($data) and $data === false) { |
|
227 | + $data = 0; |
|
228 | + } |
|
219 | 229 | |
220 | 230 | return $data; |
221 | 231 | }, $this->_newData); |
@@ -226,7 +236,9 @@ discard block |
||
226 | 236 | |
227 | 237 | $this->Connection->setPerformedQuery($insert->queryString, round(($end - $start), 5)); |
228 | 238 | |
229 | - if (is_callable($this->triggerAfter)) ($this->triggerAfter)(); |
|
239 | + if (is_callable($this->triggerAfter)) { |
|
240 | + ($this->triggerAfter)(); |
|
241 | + } |
|
230 | 242 | |
231 | 243 | if ($update) { |
232 | 244 | $this->burnError($insert); |
@@ -265,7 +277,9 @@ discard block |
||
265 | 277 | |
266 | 278 | private function burnError($statment) |
267 | 279 | { |
268 | - if (!is_null($statment->errorInfo()[1])) throw new \Exception($statment->errorInfo()[2], $statment->errorInfo()[1]); |
|
280 | + if (!is_null($statment->errorInfo()[1])) { |
|
281 | + throw new \Exception($statment->errorInfo()[2], $statment->errorInfo()[1]); |
|
282 | + } |
|
269 | 283 | } |
270 | 284 | |
271 | 285 | /** |
@@ -280,16 +294,23 @@ discard block |
||
280 | 294 | throw new \Exception($e->getMessage()); |
281 | 295 | } |
282 | 296 | |
283 | - if (!isset(static::$primary_key)) throw new \Exception('Primary key don\'t set'); |
|
297 | + if (!isset(static::$primary_key)) { |
|
298 | + throw new \Exception('Primary key don\'t set'); |
|
299 | + } |
|
284 | 300 | |
285 | - if (!is_numeric($this->{static::$primary_key})) throw new \Exception('Primary key value don\'t is valid'); |
|
301 | + if (!is_numeric($this->{static::$primary_key})) { |
|
302 | + throw new \Exception('Primary key value don\'t is valid'); |
|
303 | + } |
|
286 | 304 | |
287 | 305 | $sql = ' DELETE FROM ' . static::$table_name; |
288 | 306 | $sql .= ' WHERE ' . static::$primary_key . ' = ? '; |
289 | 307 | |
290 | 308 | $instance = self::$_instance; |
291 | 309 | |
292 | - if (is_callable($this->triggerBefore)) ($this->triggerBefore)();; |
|
310 | + if (is_callable($this->triggerBefore)) { |
|
311 | + ($this->triggerBefore)(); |
|
312 | + } |
|
313 | + ; |
|
293 | 314 | |
294 | 315 | $start = microtime(true); |
295 | 316 | |
@@ -300,7 +321,9 @@ discard block |
||
300 | 321 | |
301 | 322 | $instance->Connection->setPerformedQuery($insert->queryString, round(($end - $start), 5)); |
302 | 323 | |
303 | - if (is_callable($this->triggerAfter)) ($this->triggerAfter)(); |
|
324 | + if (is_callable($this->triggerAfter)) { |
|
325 | + ($this->triggerAfter)(); |
|
326 | + } |
|
304 | 327 | |
305 | 328 | if ($insert->rowCount() > 0) { |
306 | 329 | $logger = [ |
@@ -311,8 +334,7 @@ discard block |
||
311 | 334 | $this->saveLogger($logger); |
312 | 335 | |
313 | 336 | return true; |
314 | - } |
|
315 | - else{ return false; }; |
|
337 | + } else{ return false; }; |
|
316 | 338 | } |
317 | 339 | |
318 | 340 | /** |
@@ -332,7 +354,9 @@ discard block |
||
332 | 354 | { |
333 | 355 | self::instance(); |
334 | 356 | |
335 | - if (!isset(static::$table_name)) throw new \Exception('Don\'t set table name in model.'); |
|
357 | + if (!isset(static::$table_name)) { |
|
358 | + throw new \Exception('Don\'t set table name in model.'); |
|
359 | + } |
|
336 | 360 | |
337 | 361 | $currentTable = static::$table_name; |
338 | 362 | |
@@ -360,8 +384,12 @@ discard block |
||
360 | 384 | { |
361 | 385 | self::instance(); |
362 | 386 | |
363 | - if (!is_string($procedureName)) throw new \Exception("Procedure name is invalid."); |
|
364 | - if (!is_array($param)) throw new \Exception("Tipo de parâmetros inválidos."); |
|
387 | + if (!is_string($procedureName)) { |
|
388 | + throw new \Exception("Procedure name is invalid."); |
|
389 | + } |
|
390 | + if (!is_array($param)) { |
|
391 | + throw new \Exception("Tipo de parâmetros inválidos."); |
|
392 | + } |
|
365 | 393 | |
366 | 394 | $currentTable = static::$table_name; |
367 | 395 | |
@@ -436,13 +464,17 @@ discard block |
||
436 | 464 | throw new \Exception($e->getMessage()); |
437 | 465 | } |
438 | 466 | |
439 | - if (!is_array($parameters) and !is_numeric($parameters)) throw new \Exception('Invalid parameter type on model ' . get_called_class() . '.'); |
|
467 | + if (!is_array($parameters) and !is_numeric($parameters)) { |
|
468 | + throw new \Exception('Invalid parameter type on model ' . get_called_class() . '.'); |
|
469 | + } |
|
440 | 470 | |
441 | 471 | $instance->_current_custom_query[] = 'SELECT * FROM ' . static::$table_name . ' '; |
442 | 472 | |
443 | 473 | switch ($parameters) { |
444 | 474 | case is_numeric($parameters): |
445 | - if (!isset(static::$primary_key)) throw new \Exception("Invalid parameter type."); |
|
475 | + if (!isset(static::$primary_key)) { |
|
476 | + throw new \Exception("Invalid parameter type."); |
|
477 | + } |
|
446 | 478 | |
447 | 479 | $instance->_current_custom_query_values[] = $parameters; |
448 | 480 | $instance->_current_custom_query[] = ' WHERE ' . static::$primary_key . ' = ?'; |
@@ -465,7 +497,7 @@ discard block |
||
465 | 497 | $done->Result->setResults($clone); |
466 | 498 | |
467 | 499 | return $done; |
468 | - }else { |
|
500 | + } else { |
|
469 | 501 | return null; |
470 | 502 | } |
471 | 503 | } |
@@ -486,11 +518,15 @@ discard block |
||
486 | 518 | throw new \Exception($e->getMessage()); |
487 | 519 | } |
488 | 520 | |
489 | - if (!is_string($colunm)) throw new \Exception("Invalid parameter type."); |
|
521 | + if (!is_string($colunm)) { |
|
522 | + throw new \Exception("Invalid parameter type."); |
|
523 | + } |
|
490 | 524 | |
491 | 525 | self::$_instance->_current_custom_query[] = "SELECT $colunm FROM " . static::$table_name . ' '; |
492 | 526 | |
493 | - if (!isset(static::$primary_key)) throw new \Exception("Invalid parameter type."); |
|
527 | + if (!isset(static::$primary_key)) { |
|
528 | + throw new \Exception("Invalid parameter type."); |
|
529 | + } |
|
494 | 530 | |
495 | 531 | return self::$_instance; |
496 | 532 | } |
@@ -540,7 +576,9 @@ discard block |
||
540 | 576 | throw new \Exception($e->getMessage()); |
541 | 577 | } |
542 | 578 | |
543 | - if (!is_array($param)) throw new \Exception('Tipo de parâmetro inválido.'); |
|
579 | + if (!is_array($param)) { |
|
580 | + throw new \Exception('Tipo de parâmetro inválido.'); |
|
581 | + } |
|
544 | 582 | |
545 | 583 | $start = microtime(true); |
546 | 584 | |
@@ -585,7 +623,9 @@ discard block |
||
585 | 623 | throw new \Exception($e->getMessage()); |
586 | 624 | } |
587 | 625 | |
588 | - if (!is_array($param)) throw new \Exception('Invalid parameter type.'); |
|
626 | + if (!is_array($param)) { |
|
627 | + throw new \Exception('Invalid parameter type.'); |
|
628 | + } |
|
589 | 629 | |
590 | 630 | self::$_instance->_current_custom_query_values = $param; |
591 | 631 | |
@@ -624,7 +664,9 @@ discard block |
||
624 | 664 | */ |
625 | 665 | final protected function setTriggerAfter($closure = null) |
626 | 666 | { |
627 | - if (!is_callable($closure)) throw new \Exception('The parameter don\'t is an closure.'); |
|
667 | + if (!is_callable($closure)) { |
|
668 | + throw new \Exception('The parameter don\'t is an closure.'); |
|
669 | + } |
|
628 | 670 | |
629 | 671 | $this->triggerAfter = $closure; |
630 | 672 | |
@@ -639,7 +681,9 @@ discard block |
||
639 | 681 | */ |
640 | 682 | final protected function setTriggerBefore($closure = null) |
641 | 683 | { |
642 | - if (!is_callable($closure)) throw new \Exception('The parameter don\'t is an closure.'); |
|
684 | + if (!is_callable($closure)) { |
|
685 | + throw new \Exception('The parameter don\'t is an closure.'); |
|
686 | + } |
|
643 | 687 | |
644 | 688 | $this->triggerBefore = $closure; |
645 | 689 | |
@@ -653,7 +697,9 @@ discard block |
||
653 | 697 | */ |
654 | 698 | final protected function changeSchema($schema) |
655 | 699 | { |
656 | - if (!is_string($schema)) throw new \Exception('The parameter don\'t is an String.'); |
|
700 | + if (!is_string($schema)) { |
|
701 | + throw new \Exception('The parameter don\'t is an String.'); |
|
702 | + } |
|
657 | 703 | |
658 | 704 | $this->Connection->changeSchema($schema); |
659 | 705 | return $this; |
@@ -692,7 +738,9 @@ discard block |
||
692 | 738 | */ |
693 | 739 | final private function verifyConnection() |
694 | 740 | { |
695 | - if (is_null($this->Connection->getCurrentConnectionString())) throw new \Exception('Not set connection.'); |
|
741 | + if (is_null($this->Connection->getCurrentConnectionString())) { |
|
742 | + throw new \Exception('Not set connection.'); |
|
743 | + } |
|
696 | 744 | } |
697 | 745 | |
698 | 746 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | if (!($data instanceof self)) throw new \Exception(" It's not a model."); |
29 | 29 | |
30 | - $data = array_map(function ($object) { return $object->toArray(); }, $data); |
|
30 | + $data = array_map(function($object) { return $object->toArray(); }, $data); |
|
31 | 31 | |
32 | 32 | return $data; |
33 | 33 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | if (is_null($offset)) { |
67 | 67 | $data[] = $value; |
68 | - } else { |
|
68 | + }else { |
|
69 | 69 | $data[$offset] = $value; |
70 | 70 | } |
71 | 71 | } |
@@ -25,7 +25,9 @@ |
||
25 | 25 | */ |
26 | 26 | public static function toList($data) |
27 | 27 | { |
28 | - if (!($data instanceof self)) throw new \Exception(" It's not a model."); |
|
28 | + if (!($data instanceof self)) { |
|
29 | + throw new \Exception(" It's not a model."); |
|
30 | + } |
|
29 | 31 | |
30 | 32 | $data = array_map(function ($object) { return $object->toArray(); }, $data); |
31 | 33 |
@@ -175,8 +175,12 @@ |
||
175 | 175 | */ |
176 | 176 | final public function changeSchema($schema = null) |
177 | 177 | { |
178 | - if (!is_string($schema)) throw new \InvalidArgumentException('The parameter don\'t is an String.'); |
|
179 | - if ($this->driver == 'mysql') throw new \InvalidArgumentException('This driver not supported schemas.'); |
|
178 | + if (!is_string($schema)) { |
|
179 | + throw new \InvalidArgumentException('The parameter don\'t is an String.'); |
|
180 | + } |
|
181 | + if ($this->driver == 'mysql') { |
|
182 | + throw new \InvalidArgumentException('This driver not supported schemas.'); |
|
183 | + } |
|
180 | 184 | |
181 | 185 | $this->getConnection()->exec("SET search_path TO '$schema';"); |
182 | 186 | return $this; |
@@ -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 = [ |
29 | 31 | 'message' => $message, |
@@ -38,7 +40,9 @@ discard block |
||
38 | 40 | |
39 | 41 | public static function instance() |
40 | 42 | { |
41 | - if (!self::$_instance) self::$_instance = new self(); |
|
43 | + if (!self::$_instance) { |
|
44 | + self::$_instance = new self(); |
|
45 | + } |
|
42 | 46 | return self::$_instance; |
43 | 47 | } |
44 | 48 |