Passed
Push — main ( ed3651...616bd9 )
by BRUNO
02:00
created
src/DatalayerTrait.php 1 patch
Braces   +19 added lines, -10 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@  discard block
 block discarded – undo
34 34
      */
35 35
     private function getInstance(): ?PDO
36 36
     {
37
-        if (strpos($_SERVER['SERVER_NAME'], "homologacao") && !strpos($this->database, "Homologacao") )
38
-            $this->database .= "Homologacao";
37
+        if (strpos($_SERVER['SERVER_NAME'], "homologacao") && !strpos($this->database, "Homologacao") ) {
38
+                    $this->database .= "Homologacao";
39
+        }
39 40
 
40 41
         if (!isset($this->instance)) {
41 42
             $this->instance = Connect::getInstance($this->database);
@@ -340,18 +341,26 @@  discard block
 block discarded – undo
340 341
             $indexed = $params == array_values($params);
341 342
             foreach($params as $k=>$v) {
342 343
                 if (is_object($v)) {
343
-                    if ($v instanceof \DateTime) $v = $v->format('Y-m-d H:i:s');
344
-                    else continue;
344
+                    if ($v instanceof \DateTime) {
345
+                        $v = $v->format('Y-m-d H:i:s');
346
+                    } else {
347
+                        continue;
348
+                    }
349
+                } elseif (is_string($v)) {
350
+                    $v="'$v'";
351
+                } elseif ($v === null) {
352
+                    $v='NULL';
353
+                } elseif (is_array($v)) {
354
+                    $v = implode(',', $v);
345 355
                 }
346
-                elseif (is_string($v)) $v="'$v'";
347
-                elseif ($v === null) $v='NULL';
348
-                elseif (is_array($v)) $v = implode(',', $v);
349 356
 
350 357
                 if ($indexed) {
351 358
                     $sql_string = preg_replace('/\?/', $v, $sql_string, 1);
352
-                }
353
-                else {
354
-                    if ($k[0] != ':') $k = ':'.$k; //add leading colon if it was left out
359
+                } else {
360
+                    if ($k[0] != ':') {
361
+                        $k = ':'.$k;
362
+                    }
363
+                    //add leading colon if it was left out
355 364
                     $sql_string = str_replace($k,$v,$sql_string);
356 365
                 }
357 366
             }
Please login to merge, or discard this patch.
src/ModelAbstract.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,8 +22,9 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function __construct(array $params = null)
24 24
     {
25
-        if (!empty($params))
26
-            $this->fromMapToModel($params);
25
+        if (!empty($params)) {
26
+                    $this->fromMapToModel($params);
27
+        }
27 28
     }
28 29
 
29 30
     /**
@@ -82,7 +83,9 @@  discard block
 block discarded – undo
82 83
         $data = (object) $this->toMap();
83 84
         $re_2 = new ReflectionObject($data);
84 85
         $classname = get_class($this);
85
-        if ($pos = strrpos($classname, '\\')) $classname = substr($classname, $pos + 1);
86
+        if ($pos = strrpos($classname, '\\')) {
87
+            $classname = substr($classname, $pos + 1);
88
+        }
86 89
         return $classname .' {' . implode(', ', array_map(
87 90
                 function($p_0) use ($data)
88 91
                 {
Please login to merge, or discard this patch.
src/Crud.php 1 patch
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
51 51
         $sql = "INSERT INTO {$this->tableName} ({$fields}) VALUES ({$numparams})";
52 52
         if ($debug) { echo $sql; echo "<pre>"; print_r($values); echo "</pre>"; return; }
53 53
         $result = $this->executeSQL($sql, $values);
54
-        if (empty($result))
55
-            return false;
54
+        if (empty($result)) {
55
+                    return false;
56
+        }
56 57
         return true;
57 58
     }
58 59
 
@@ -84,8 +85,9 @@  discard block
 block discarded – undo
84 85
             $query = "INSERT INTO $this->tableName";
85 86
             $values = [];
86 87
             $dataColumns = array_keys($params);
87
-            if (isset ($dataColumns[0]))
88
-                $query .= ' (`' . implode('`, `', $dataColumns) . '`) ';
88
+            if (isset ($dataColumns[0])) {
89
+                            $query .= ' (`' . implode('`, `', $dataColumns) . '`) ';
90
+            }
89 91
             $query .= ' VALUES (';
90 92
 
91 93
             foreach ($dataColumns as $index => $column) {
@@ -97,8 +99,9 @@  discard block
 block discarded – undo
97 99
             $query .= ')';
98 100
 
99 101
             $result = $this->executeSQL($query, $values);
100
-            if (empty($result))
101
-                return false;
102
+            if (empty($result)) {
103
+                            return false;
104
+            }
102 105
             return true;
103 106
         } else {
104 107
             return false;
@@ -123,8 +126,9 @@  discard block
 block discarded – undo
123 126
         if (isset($where)) { $sql .= " WHERE $where"; }
124 127
         if ($debug) { echo $sql; echo "<pre>"; print_r($values); echo "</pre>"; return; }
125 128
         $result = $this->executeSQL($sql, $values);
126
-        if (empty($result))
127
-            return false;
129
+        if (empty($result)) {
130
+                    return false;
131
+        }
128 132
         return true;
129 133
     }
130 134
 
@@ -165,12 +169,14 @@  discard block
 block discarded – undo
165 169
             }
166 170
             $query = rtrim($query, ", ");
167 171
 
168
-            if (!empty($where))
169
-                $query .= " WHERE {$where}";
172
+            if (!empty($where)) {
173
+                            $query .= " WHERE {$where}";
174
+            }
170 175
 
171 176
             $result = $this->executeSQL($query, $values);
172
-            if (empty($result))
173
-                return false;
177
+            if (empty($result)) {
178
+                            return false;
179
+            }
174 180
             return true;
175 181
         } else {
176 182
             return false;
@@ -190,8 +196,9 @@  discard block
 block discarded – undo
190 196
         if (!empty($where)) { $sql .= " WHERE $where"; }
191 197
         if ($debug) { echo $sql; echo "<pre>"; print_r($values); echo "</pre>"; return; }
192 198
         $result = $this->executeSQL($sql, $values);
193
-        if (empty($result))
194
-            return false;
199
+        if (empty($result)) {
200
+                    return false;
201
+        }
195 202
         return true;
196 203
     }
197 204
 
Please login to merge, or discard this patch.