@@ -80,9 +80,9 @@ discard block  | 
                                                    ||
| 80 | 80 | |
| 81 | 81 | $this->childClass = new ChildSimplePHP(get_called_class());  | 
                                                        
| 82 | 82 | |
| 83 | - if($tableName) $this->table = $tableName;  | 
                                                        |
| 83 | + if ($tableName) $this->table = $tableName;  | 
                                                        |
| 84 | 84 | |
| 85 | - if($primaryKey) $this->primary = $primaryKey;  | 
                                                        |
| 85 | + if ($primaryKey) $this->primary = $primaryKey;  | 
                                                        |
| 86 | 86 | }  | 
                                                        
| 87 | 87 | |
| 88 | 88 | private function setRealTable() : ?SimplePHP  | 
                                                        
@@ -116,9 +116,9 @@ discard block  | 
                                                    ||
| 116 | 116 | public function where(Array $where, String $condition = 'AND'): ?SimplePHP  | 
                                                        
| 117 | 117 |      { | 
                                                        
| 118 | 118 | $this->where = '';  | 
                                                        
| 119 | -        foreach($where as $enclosures) { | 
                                                        |
| 120 | - $split = isset($enclosures[3]) && !$enclosures[3] ? $enclosures[2] : "'".$enclosures[2]."'";  | 
                                                        |
| 121 | -            $this->where .= $enclosures[0]." ".$enclosures[1]." ".$split." {$condition} "; | 
                                                        |
| 119 | +        foreach ($where as $enclosures) { | 
                                                        |
| 120 | + $split = isset($enclosures[3]) && !$enclosures[3] ? $enclosures[2] : "'" . $enclosures[2] . "'";  | 
                                                        |
| 121 | +            $this->where .= $enclosures[0] . " " . $enclosures[1] . " " . $split . " {$condition} "; | 
                                                        |
| 122 | 122 | }  | 
                                                        
| 123 | 123 |          $this->where = "WHERE " . rtrim($this->where, " {$condition} "); | 
                                                        
| 124 | 124 | |
@@ -143,9 +143,9 @@ discard block  | 
                                                    ||
| 143 | 143 | public function orWhere(Array $orWhere, String $condition = 'AND'): ?SimplePHP  | 
                                                        
| 144 | 144 |      { | 
                                                        
| 145 | 145 | $moreWhere = '';  | 
                                                        
| 146 | -        foreach($orWhere as $enclosures) { | 
                                                        |
| 147 | - $split = isset($enclosures[3]) && !$enclosures[3] ? $enclosures[2] : "'".$enclosures[2]."'";  | 
                                                        |
| 148 | -            $moreWhere .= $enclosures[0]." ".$enclosures[1]." ".$split." {$condition} "; | 
                                                        |
| 146 | +        foreach ($orWhere as $enclosures) { | 
                                                        |
| 147 | + $split = isset($enclosures[3]) && !$enclosures[3] ? $enclosures[2] : "'" . $enclosures[2] . "'";  | 
                                                        |
| 148 | +            $moreWhere .= $enclosures[0] . " " . $enclosures[1] . " " . $split . " {$condition} "; | 
                                                        |
| 149 | 149 | }  | 
                                                        
| 150 | 150 |          $this->where .= " OR " . rtrim($moreWhere, " {$condition} "); | 
                                                        
| 151 | 151 | |
@@ -189,7 +189,7 @@ discard block  | 
                                                    ||
| 189 | 189 | */  | 
                                                        
| 190 | 190 | public function orderBy(String $prop, String $ordenation = 'ASC'): ?SimplePHP  | 
                                                        
| 191 | 191 |      { | 
                                                        
| 192 | -        if(mb_strlen($this->order) < 9) { | 
                                                        |
| 192 | +        if (mb_strlen($this->order) < 9) { | 
                                                        |
| 193 | 193 |              $this->order = "ORDER BY {$prop} {$ordenation}"; | 
                                                        
| 194 | 194 |          } else { | 
                                                        
| 195 | 195 |              $this->order .= ", {$prop} {$ordenation}"; | 
                                                        
@@ -203,7 +203,7 @@ discard block  | 
                                                    ||
| 203 | 203 | */  | 
                                                        
| 204 | 204 | public function groupBy(String $prop): ?SimplePHP  | 
                                                        
| 205 | 205 |      { | 
                                                        
| 206 | -        if(mb_strlen($this->group) < 9) { | 
                                                        |
| 206 | +        if (mb_strlen($this->group) < 9) { | 
                                                        |
| 207 | 207 |              $this->group = "GROUP BY {$prop}"; | 
                                                        
| 208 | 208 |          } else { | 
                                                        
| 209 | 209 |              $this->group .= ", {$prop}"; | 
                                                        
@@ -218,16 +218,16 @@ discard block  | 
                                                    ||
| 218 | 218 | */  | 
                                                        
| 219 | 219 | public function __call(String $name, $arguments)  | 
                                                        
| 220 | 220 |      { | 
                                                        
| 221 | - if($name === 'skip')  | 
                                                        |
| 221 | + if ($name === 'skip')  | 
                                                        |
| 222 | 222 | return $this->offset($arguments[0]);  | 
                                                        
| 223 | 223 | |
| 224 | - if($name === 'take')  | 
                                                        |
| 224 | + if ($name === 'take')  | 
                                                        |
| 225 | 225 | return $this->limit($arguments[0]);  | 
                                                        
| 226 | 226 | |
| 227 | - if($name === 'get')  | 
                                                        |
| 227 | + if ($name === 'get')  | 
                                                        |
| 228 | 228 | return $this->execute();  | 
                                                        
| 229 | 229 | |
| 230 | - if($name === 'first')  | 
                                                        |
| 230 | + if ($name === 'first')  | 
                                                        |
| 231 | 231 | return $this->execute(true);  | 
                                                        
| 232 | 232 | |
| 233 | 233 |          return $this->writeLog("This method does not exist at the SimplePHP: \"<b>{$name}</b>\"."); | 
                                                        
@@ -300,7 +300,7 @@ discard block  | 
                                                    ||
| 300 | 300 |      { | 
                                                        
| 301 | 301 | $this->type = $type;  | 
                                                        
| 302 | 302 |          try { | 
                                                        
| 303 | - if(!is_object(Connection::getConnection()))  | 
                                                        |
| 303 | + if (!is_object(Connection::getConnection()))  | 
                                                        |
| 304 | 304 |                  return $this->writeLog("Connection failed. Check your connection config and try again.", true); | 
                                                        
| 305 | 305 | |
| 306 | 306 |              $execute = Connection::getConnection()->query("SELECT {$this->params} FROM {$this->table} {$this->where} {$this->group} {$this->order} {$this->limit} {$this->offset}"); | 
                                                        
@@ -381,7 +381,7 @@ discard block  | 
                                                    ||
| 381 | 381 |          $log = new Logger('SimplePHP'); | 
                                                        
| 382 | 382 | $log->pushHandler(new StreamHandler(self::$config["pathLog"], Logger::WARNING));  | 
                                                        
| 383 | 383 | |
| 384 | -        if($pdo) { | 
                                                        |
| 384 | +        if ($pdo) { | 
                                                        |
| 385 | 385 | $log->error($message);  | 
                                                        
| 386 | 386 | return;  | 
                                                        
| 387 | 387 | }  | 
                                                        
@@ -80,9 +80,13 @@ discard block  | 
                                                    ||
| 80 | 80 | |
| 81 | 81 | $this->childClass = new ChildSimplePHP(get_called_class());  | 
                                                        
| 82 | 82 | |
| 83 | - if($tableName) $this->table = $tableName;  | 
                                                        |
| 83 | +        if($tableName) { | 
                                                        |
| 84 | + $this->table = $tableName;  | 
                                                        |
| 85 | + }  | 
                                                        |
| 84 | 86 | |
| 85 | - if($primaryKey) $this->primary = $primaryKey;  | 
                                                        |
| 87 | +        if($primaryKey) { | 
                                                        |
| 88 | + $this->primary = $primaryKey;  | 
                                                        |
| 89 | + }  | 
                                                        |
| 86 | 90 | }  | 
                                                        
| 87 | 91 | |
| 88 | 92 | private function setRealTable() : ?SimplePHP  | 
                                                        
@@ -218,17 +222,21 @@ discard block  | 
                                                    ||
| 218 | 222 | */  | 
                                                        
| 219 | 223 | public function __call(String $name, $arguments)  | 
                                                        
| 220 | 224 |      { | 
                                                        
| 221 | - if($name === 'skip')  | 
                                                        |
| 222 | - return $this->offset($arguments[0]);  | 
                                                        |
| 225 | +        if($name === 'skip') { | 
                                                        |
| 226 | + return $this->offset($arguments[0]);  | 
                                                        |
| 227 | + }  | 
                                                        |
| 223 | 228 | |
| 224 | - if($name === 'take')  | 
                                                        |
| 225 | - return $this->limit($arguments[0]);  | 
                                                        |
| 229 | +        if($name === 'take') { | 
                                                        |
| 230 | + return $this->limit($arguments[0]);  | 
                                                        |
| 231 | + }  | 
                                                        |
| 226 | 232 | |
| 227 | - if($name === 'get')  | 
                                                        |
| 228 | - return $this->execute();  | 
                                                        |
| 233 | +        if($name === 'get') { | 
                                                        |
| 234 | + return $this->execute();  | 
                                                        |
| 235 | + }  | 
                                                        |
| 229 | 236 | |
| 230 | - if($name === 'first')  | 
                                                        |
| 231 | - return $this->execute(true);  | 
                                                        |
| 237 | +        if($name === 'first') { | 
                                                        |
| 238 | + return $this->execute(true);  | 
                                                        |
| 239 | + }  | 
                                                        |
| 232 | 240 | |
| 233 | 241 |          return $this->writeLog("This method does not exist at the SimplePHP: \"<b>{$name}</b>\"."); | 
                                                        
| 234 | 242 | }  | 
                                                        
@@ -250,7 +258,9 @@ discard block  | 
                                                    ||
| 250 | 258 |      { | 
                                                        
| 251 | 259 |          if (!empty($this->excepts)) { | 
                                                        
| 252 | 260 |              foreach ($this->excepts as $except) { | 
                                                        
| 253 | - if (isset($this->data[$except])) unset($this->data[$except]);  | 
                                                        |
| 261 | +                if (isset($this->data[$except])) { | 
                                                        |
| 262 | + unset($this->data[$except]);  | 
                                                        |
| 263 | + }  | 
                                                        |
| 254 | 264 | }  | 
                                                        
| 255 | 265 | }  | 
                                                        
| 256 | 266 | }  | 
                                                        
@@ -300,8 +310,9 @@ discard block  | 
                                                    ||
| 300 | 310 |      { | 
                                                        
| 301 | 311 | $this->type = $type;  | 
                                                        
| 302 | 312 |          try { | 
                                                        
| 303 | - if(!is_object(Connection::getConnection()))  | 
                                                        |
| 304 | -                return $this->writeLog("Connection failed. Check your connection config and try again.", true); | 
                                                        |
| 313 | +            if(!is_object(Connection::getConnection())) { | 
                                                        |
| 314 | +                            return $this->writeLog("Connection failed. Check your connection config and try again.", true); | 
                                                        |
| 315 | + }  | 
                                                        |
| 305 | 316 | |
| 306 | 317 |              $execute = Connection::getConnection()->query("SELECT {$this->params} FROM {$this->table} {$this->where} {$this->group} {$this->order} {$this->limit} {$this->offset}"); | 
                                                        
| 307 | 318 | $execute->rowCount() > 1 ?  | 
                                                        
@@ -27,7 +27,7 @@ discard block  | 
                                                    ||
| 27 | 27 |          $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); | 
                                                        
| 28 | 28 |          $text = preg_replace('~[^-\w]+~', '', trim($text, '-')); | 
                                                        
| 29 | 29 |          $text = preg_replace('~-+~', '-', strtolower($text)); | 
                                                        
| 30 | -        if(empty($text)) { return null; } | 
                                                        |
| 30 | +        if (empty($text)) { return null; } | 
                                                        |
| 31 | 31 | return $text;  | 
                                                        
| 32 | 32 | }  | 
                                                        
| 33 | 33 | |
@@ -82,8 +82,8 @@ discard block  | 
                                                    ||
| 82 | 82 | * @return string  | 
                                                        
| 83 | 83 | */  | 
                                                        
| 84 | 84 |      public function getAdressIP() { | 
                                                        
| 85 | -        if(array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { | 
                                                        |
| 86 | -            if(strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') > 0) { | 
                                                        |
| 85 | +        if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { | 
                                                        |
| 86 | +            if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') > 0) { | 
                                                        |
| 87 | 87 |                  $addr = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']); | 
                                                        
| 88 | 88 | return trim($addr[0]);  | 
                                                        
| 89 | 89 |              } else { | 
                                                        
@@ -89,8 +89,7 @@  | 
                                                    ||
| 89 | 89 |              } else { | 
                                                        
| 90 | 90 | return $_SERVER['HTTP_X_FORWARDED_FOR'];  | 
                                                        
| 91 | 91 | }  | 
                                                        
| 92 | - }  | 
                                                        |
| 93 | -        else { | 
                                                        |
| 92 | +        } else { | 
                                                        |
| 94 | 93 | return $_SERVER['REMOTE_ADDR'];  | 
                                                        
| 95 | 94 | }  | 
                                                        
| 96 | 95 | }  | 
                                                        
@@ -41,7 +41,7 @@ discard block  | 
                                                    ||
| 41 | 41 | PDO::ATTR_ORACLE_NULLS => PDO::NULL_EMPTY_STRING  | 
                                                        
| 42 | 42 | ]  | 
                                                        
| 43 | 43 | ];  | 
                                                        
| 44 | -        if(empty(self::$conn)) { | 
                                                        |
| 44 | +        if (empty(self::$conn)) { | 
                                                        |
| 45 | 45 | self::connectPdo();  | 
                                                        
| 46 | 46 | }  | 
                                                        
| 47 | 47 | |
@@ -55,7 +55,7 @@ discard block  | 
                                                    ||
| 55 | 55 |      { | 
                                                        
| 56 | 56 | date_default_timezone_set(self::$config['timezone']);  | 
                                                        
| 57 | 57 | |
| 58 | -        if(empty(self::$conn)) { | 
                                                        |
| 58 | +        if (empty(self::$conn)) { | 
                                                        |
| 59 | 59 |              try { | 
                                                        
| 60 | 60 | self::$conn = new PDO(  | 
                                                        
| 61 | 61 | self::$config['driver'] . ":host=" .  | 
                                                        
@@ -67,7 +67,7 @@ discard block  | 
                                                    ||
| 67 | 67 | self::$config['password'],  | 
                                                        
| 68 | 68 | self::$config['options']  | 
                                                        
| 69 | 69 | );  | 
                                                        
| 70 | -            } catch(PDOException $exception) { | 
                                                        |
| 70 | +            } catch (PDOException $exception) { | 
                                                        |
| 71 | 71 | return false;  | 
                                                        
| 72 | 72 | }  | 
                                                        
| 73 | 73 | }  | 
                                                        
@@ -78,10 +78,10 @@ discard block  | 
                                                    ||
| 78 | 78 | $realDirectory = dirname(__DIR__, 5);  | 
                                                        
| 79 | 79 | $completeDirectoryToLog = $realDirectory . DIRECTORY_SEPARATOR . $_ENV['PATH_LOG'];  | 
                                                        
| 80 | 80 | |
| 81 | -        if(!file_exists($completeDirectoryToLog . 'Logs.log')) { | 
                                                        |
| 81 | +        if (!file_exists($completeDirectoryToLog . 'Logs.log')) { | 
                                                        |
| 82 | 82 |              try { | 
                                                        
| 83 | 83 | fopen($completeDirectoryToLog . 'Logs.log', 'a');  | 
                                                        
| 84 | -            } catch(Exception $error) { | 
                                                        |
| 84 | +            } catch (Exception $error) { | 
                                                        |
| 85 | 85 | return false;  | 
                                                        
| 86 | 86 | }  | 
                                                        
| 87 | 87 | }  |