| @@ -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 | |
| @@ -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 | } | 
| @@ -207,14 +213,18 @@ discard block | ||
| 207 | 213 | $sql .= " ($repeat); "; | 
| 208 | 214 | } | 
| 209 | 215 | |
| 210 | - if (is_callable($this->triggerBefore)) ($this->triggerBefore)(); | |
| 216 | +        if (is_callable($this->triggerBefore)) { | |
| 217 | + ($this->triggerBefore)(); | |
| 218 | + } | |
| 211 | 219 | |
| 212 | 220 | $start = microtime(true); | 
| 213 | 221 | $insert = $this->Connection->getConnection()->prepare($sql); | 
| 214 | 222 | $this->burnError($insert); | 
| 215 | 223 | |
| 216 | 224 |          $this->_newData = array_map(function ($data) { | 
| 217 | - if (is_bool($data) and $data === false) $data = 0; | |
| 225 | +            if (is_bool($data) and $data === false) { | |
| 226 | + $data = 0; | |
| 227 | + } | |
| 218 | 228 | |
| 219 | 229 | return $data; | 
| 220 | 230 | }, $this->_newData); | 
| @@ -225,7 +235,9 @@ discard block | ||
| 225 | 235 | |
| 226 | 236 | $this->Connection->setPerformedQuery($insert->queryString, round(($end - $start), 5)); | 
| 227 | 237 | |
| 228 | - if (is_callable($this->triggerAfter)) ($this->triggerAfter)(); | |
| 238 | +        if (is_callable($this->triggerAfter)) { | |
| 239 | + ($this->triggerAfter)(); | |
| 240 | + } | |
| 229 | 241 | |
| 230 | 242 |          if ($update) { | 
| 231 | 243 | $this->burnError($insert); | 
| @@ -264,7 +276,9 @@ discard block | ||
| 264 | 276 | |
| 265 | 277 | private function burnError($statment) | 
| 266 | 278 |      { | 
| 267 | - if (!is_null($statment->errorInfo()[1])) throw new \Exception($statment->errorInfo()[2], $statment->errorInfo()[1]); | |
| 279 | +        if (!is_null($statment->errorInfo()[1])) { | |
| 280 | + throw new \Exception($statment->errorInfo()[2], $statment->errorInfo()[1]); | |
| 281 | + } | |
| 268 | 282 | } | 
| 269 | 283 | |
| 270 | 284 | /** | 
| @@ -279,16 +293,23 @@ discard block | ||
| 279 | 293 | throw new \Exception($e->getMessage()); | 
| 280 | 294 | } | 
| 281 | 295 | |
| 282 | -        if (!isset(static::$primary_key)) throw new \Exception('Primary key don\'t set'); | |
| 296 | +        if (!isset(static::$primary_key)) { | |
| 297 | +         throw new \Exception('Primary key don\'t set'); | |
| 298 | + } | |
| 283 | 299 | |
| 284 | -        if (!is_numeric($this->{static::$primary_key})) throw new \Exception('Primary key value don\'t is valid'); | |
| 300 | +        if (!is_numeric($this->{static::$primary_key})) { | |
| 301 | +         throw new \Exception('Primary key value don\'t is valid'); | |
| 302 | + } | |
| 285 | 303 | |
| 286 | 304 | $sql = ' DELETE FROM ' . static::$table_name; | 
| 287 | 305 | $sql .= ' WHERE ' . static::$primary_key . ' = ? '; | 
| 288 | 306 | |
| 289 | 307 | $instance = self::$_instance; | 
| 290 | 308 | |
| 291 | - if (is_callable($this->triggerBefore)) ($this->triggerBefore)();; | |
| 309 | +        if (is_callable($this->triggerBefore)) { | |
| 310 | + ($this->triggerBefore)(); | |
| 311 | + } | |
| 312 | + ; | |
| 292 | 313 | |
| 293 | 314 | $start = microtime(true); | 
| 294 | 315 | |
| @@ -299,7 +320,9 @@ discard block | ||
| 299 | 320 | |
| 300 | 321 | $instance->Connection->setPerformedQuery($insert->queryString, round(($end - $start), 5)); | 
| 301 | 322 | |
| 302 | - if (is_callable($this->triggerAfter)) ($this->triggerAfter)(); | |
| 323 | +        if (is_callable($this->triggerAfter)) { | |
| 324 | + ($this->triggerAfter)(); | |
| 325 | + } | |
| 303 | 326 | |
| 304 | 327 |          if ($insert->rowCount() > 0) { | 
| 305 | 328 | $logger = [ | 
| @@ -310,8 +333,7 @@ discard block | ||
| 310 | 333 | $this->saveLogger($logger); | 
| 311 | 334 | |
| 312 | 335 | return true; | 
| 313 | - } | |
| 314 | -        else{ return false; }; | |
| 336 | +        } else{ return false; }; | |
| 315 | 337 | } | 
| 316 | 338 | |
| 317 | 339 | /** | 
| @@ -331,7 +353,9 @@ discard block | ||
| 331 | 353 |      { | 
| 332 | 354 | self::instance(); | 
| 333 | 355 | |
| 334 | -        if (!isset(static::$table_name)) throw new \Exception('Don\'t set table name in model.'); | |
| 356 | +        if (!isset(static::$table_name)) { | |
| 357 | +         throw new \Exception('Don\'t set table name in model.'); | |
| 358 | + } | |
| 335 | 359 | |
| 336 | 360 | $currentTable = static::$table_name; | 
| 337 | 361 | |
| @@ -359,8 +383,12 @@ discard block | ||
| 359 | 383 |      { | 
| 360 | 384 | self::instance(); | 
| 361 | 385 | |
| 362 | -        if (!is_string($procedureName)) throw new \Exception("Procedure name is invalid."); | |
| 363 | -        if (!is_array($param)) throw new \Exception("Tipo de parâmetros inválidos."); | |
| 386 | +        if (!is_string($procedureName)) { | |
| 387 | +         throw new \Exception("Procedure name is invalid."); | |
| 388 | + } | |
| 389 | +        if (!is_array($param)) { | |
| 390 | +         throw new \Exception("Tipo de parâmetros inválidos."); | |
| 391 | + } | |
| 364 | 392 | |
| 365 | 393 | $currentTable = static::$table_name; | 
| 366 | 394 | |
| @@ -435,13 +463,17 @@ discard block | ||
| 435 | 463 | throw new \Exception($e->getMessage()); | 
| 436 | 464 | } | 
| 437 | 465 | |
| 438 | -        if (!is_array($parameters) and !is_numeric($parameters)) throw new \Exception('Invalid parameter type on model ' . get_called_class() . '.'); | |
| 466 | +        if (!is_array($parameters) and !is_numeric($parameters)) { | |
| 467 | +         throw new \Exception('Invalid parameter type on model ' . get_called_class() . '.'); | |
| 468 | + } | |
| 439 | 469 | |
| 440 | 470 | $instance->_current_custom_query[] = 'SELECT * FROM ' . static::$table_name . ' '; | 
| 441 | 471 | |
| 442 | 472 |          switch ($parameters) { | 
| 443 | 473 | case is_numeric($parameters): | 
| 444 | -                if (!isset(static::$primary_key)) throw new \Exception("Invalid parameter type."); | |
| 474 | +                if (!isset(static::$primary_key)) { | |
| 475 | +                 throw new \Exception("Invalid parameter type."); | |
| 476 | + } | |
| 445 | 477 | |
| 446 | 478 | $instance->_current_custom_query_values[] = $parameters; | 
| 447 | 479 | $instance->_current_custom_query[] = ' WHERE ' . static::$primary_key . ' = ?'; | 
| @@ -464,7 +496,7 @@ discard block | ||
| 464 | 496 | $done->Result->setResults($clone); | 
| 465 | 497 | |
| 466 | 498 | return $done; | 
| 467 | -        }else { | |
| 499 | +        } else { | |
| 468 | 500 | return null; | 
| 469 | 501 | } | 
| 470 | 502 | } | 
| @@ -485,11 +517,15 @@ discard block | ||
| 485 | 517 | throw new \Exception($e->getMessage()); | 
| 486 | 518 | } | 
| 487 | 519 | |
| 488 | -        if (!is_string($colunm)) throw new \Exception("Invalid parameter type."); | |
| 520 | +        if (!is_string($colunm)) { | |
| 521 | +         throw new \Exception("Invalid parameter type."); | |
| 522 | + } | |
| 489 | 523 | |
| 490 | 524 | self::$_instance->_current_custom_query[] = "SELECT $colunm FROM " . static::$table_name . ' '; | 
| 491 | 525 | |
| 492 | -        if (!isset(static::$primary_key)) throw new \Exception("Invalid parameter type."); | |
| 526 | +        if (!isset(static::$primary_key)) { | |
| 527 | +         throw new \Exception("Invalid parameter type."); | |
| 528 | + } | |
| 493 | 529 | |
| 494 | 530 | return self::$_instance; | 
| 495 | 531 | } | 
| @@ -539,7 +575,9 @@ discard block | ||
| 539 | 575 | throw new \Exception($e->getMessage()); | 
| 540 | 576 | } | 
| 541 | 577 | |
| 542 | -        if (!is_array($param)) throw new \Exception('Tipo de parâmetro inválido.'); | |
| 578 | +        if (!is_array($param)) { | |
| 579 | +         throw new \Exception('Tipo de parâmetro inválido.'); | |
| 580 | + } | |
| 543 | 581 | |
| 544 | 582 | $start = microtime(true); | 
| 545 | 583 | |
| @@ -584,7 +622,9 @@ discard block | ||
| 584 | 622 | throw new \Exception($e->getMessage()); | 
| 585 | 623 | } | 
| 586 | 624 | |
| 587 | -        if (!is_array($param)) throw new \Exception('Invalid parameter type.'); | |
| 625 | +        if (!is_array($param)) { | |
| 626 | +         throw new \Exception('Invalid parameter type.'); | |
| 627 | + } | |
| 588 | 628 | |
| 589 | 629 | self::$_instance->_current_custom_query_values = $param; | 
| 590 | 630 | |
| @@ -623,7 +663,9 @@ discard block | ||
| 623 | 663 | */ | 
| 624 | 664 | final protected function setTriggerAfter($closure = null) | 
| 625 | 665 |      { | 
| 626 | -        if (!is_callable($closure)) throw new \Exception('The parameter don\'t is an closure.'); | |
| 666 | +        if (!is_callable($closure)) { | |
| 667 | +         throw new \Exception('The parameter don\'t is an closure.'); | |
| 668 | + } | |
| 627 | 669 | |
| 628 | 670 | $this->triggerAfter = $closure; | 
| 629 | 671 | |
| @@ -638,7 +680,9 @@ discard block | ||
| 638 | 680 | */ | 
| 639 | 681 | final protected function setTriggerBefore($closure = null) | 
| 640 | 682 |      { | 
| 641 | -        if (!is_callable($closure)) throw new \Exception('The parameter don\'t is an closure.'); | |
| 683 | +        if (!is_callable($closure)) { | |
| 684 | +         throw new \Exception('The parameter don\'t is an closure.'); | |
| 685 | + } | |
| 642 | 686 | |
| 643 | 687 | $this->triggerBefore = $closure; | 
| 644 | 688 | |
| @@ -652,7 +696,9 @@ discard block | ||
| 652 | 696 | */ | 
| 653 | 697 | final protected function changeSchema($schema) | 
| 654 | 698 |      { | 
| 655 | -        if (!is_string($schema)) throw new \Exception('The parameter don\'t is an String.'); | |
| 699 | +        if (!is_string($schema)) { | |
| 700 | +         throw new \Exception('The parameter don\'t is an String.'); | |
| 701 | + } | |
| 656 | 702 | |
| 657 | 703 | $this->Connection->changeSchema($schema); | 
| 658 | 704 | return $this; | 
| @@ -691,7 +737,9 @@ discard block | ||
| 691 | 737 | */ | 
| 692 | 738 | final private function verifyConnection() | 
| 693 | 739 |      { | 
| 694 | -        if (is_null($this->Connection->getCurrentConnectionString())) throw new \Exception('Not set connection.'); | |
| 740 | +        if (is_null($this->Connection->getCurrentConnectionString())) { | |
| 741 | +         throw new \Exception('Not set connection.'); | |
| 742 | + } | |
| 695 | 743 | } | 
| 696 | 744 | |
| 697 | 745 | /** | 
| @@ -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 | |
| @@ -42,7 +42,7 @@ | ||
| 42 | 42 | $this->results = $closure($connection); | 
| 43 | 43 |                  if ($this->results === false) { | 
| 44 | 44 | $connection->rollbackTransaction(); | 
| 45 | -                } else { | |
| 45 | +                }else { | |
| 46 | 46 | $connection->commitTransaction(); | 
| 47 | 47 | } | 
| 48 | 48 |              } catch (\Exception $e) { |