Passed
Push — main ( 0cf401...c49a8e )
by BRUNO
01:47
created
src/DatalayerTrait.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -310,8 +310,8 @@
 block discarded – undo
310 310
     }
311 311
 
312 312
     /**
313
-    * RETORNAR O ULTIMO ID INSERIDO
314
-    */
313
+     * RETORNAR O ULTIMO ID INSERIDO
314
+     */
315 315
     private function lastId()
316 316
     {
317 317
         $this->getInstance();
Please login to merge, or discard this 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.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  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") )
37
+        if (strpos($_SERVER['SERVER_NAME'], "homologacao") && !strpos($this->database, "Homologacao"))
38 38
             $this->database .= "Homologacao";
39 39
 
40 40
         if (!isset($this->instance)) {
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             $this->prepare->execute($params);
59 59
             $this->setLogSQL($query, $params);
60 60
         } catch (PDOException $e) {
61
-            Connect::setError($e,$query);
61
+            Connect::setError($e, $query);
62 62
             return false;
63 63
         }
64 64
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @param $prepare
70 70
      * @return int
71 71
      */
72
-    protected function count($prepare=null): int
72
+    protected function count($prepare = null): int
73 73
     {
74 74
         try {
75 75
             $prepare = empty($prepare) ? $this->prepare : $prepare;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * @param $prepare
88 88
      * @return array|false
89 89
      */
90
-    protected function fetchArrayAssoc($prepare=null): array
90
+    protected function fetchArrayAssoc($prepare = null): array
91 91
     {
92 92
         try {
93 93
             $prepare = empty($prepare) ? $this->prepare : $prepare;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @param $prepare
105 105
      * @return array|false
106 106
      */
107
-    protected function fetchArrayObj($prepare=null): array
107
+    protected function fetchArrayObj($prepare = null): array
108 108
     {
109 109
         try {
110 110
             $prepare = empty($prepare) ? $this->prepare : $prepare;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      * @param String|null $class
123 123
      * @return array|false
124 124
      */
125
-    protected function fetchArrayClass($prepare=null, String $class=null): array
125
+    protected function fetchArrayClass($prepare = null, String $class = null): array
126 126
     {
127 127
         try {
128 128
             $prepare = empty($prepare) ? $this->prepare : $prepare;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      * @param $prepare
141 141
      * @return array|false
142 142
      */
143
-    protected function fetchOneAssoc($prepare=null): array
143
+    protected function fetchOneAssoc($prepare = null): array
144 144
     {
145 145
         try {
146 146
             $prepare = empty($prepare) ? $this->prepare : $prepare;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      * @param $prepare
157 157
      * @return stdClass|false
158 158
      */
159
-    protected function fetchOneObj($prepare=null): stdClass
159
+    protected function fetchOneObj($prepare = null): stdClass
160 160
     {
161 161
         try {
162 162
             $prepare = empty($prepare) ? $this->prepare : $prepare;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      * @param String|null $class
174 174
      * @return array|false
175 175
      */
176
-    protected function fetchOneClass($prepare=null, String $class=null): object
176
+    protected function fetchOneClass($prepare = null, String $class = null): object
177 177
     {
178 178
         try {
179 179
             $prepare = empty($prepare) ? $this->prepare : $prepare;
@@ -260,21 +260,21 @@  discard block
 block discarded – undo
260 260
     function setLogSQL($sql_string, array $params = null) {
261 261
         if (!empty($params)) {
262 262
             $indexed = $params == array_values($params);
263
-            foreach($params as $k=>$v) {
263
+            foreach ($params as $k=>$v) {
264 264
                 if (is_object($v)) {
265 265
                     if ($v instanceof \DateTime) $v = $v->format('Y-m-d H:i:s');
266 266
                     else continue;
267 267
                 }
268
-                elseif (is_string($v)) $v="'$v'";
269
-                elseif ($v === null) $v='NULL';
268
+                elseif (is_string($v)) $v = "'$v'";
269
+                elseif ($v === null) $v = 'NULL';
270 270
                 elseif (is_array($v)) $v = implode(',', $v);
271 271
 
272 272
                 if ($indexed) {
273 273
                     $sql_string = preg_replace('/\?/', $v, $sql_string, 1);
274 274
                 }
275 275
                 else {
276
-                    if ($k[0] != ':') $k = ':'.$k; //add leading colon if it was left out
277
-                    $sql_string = str_replace($k,$v,$sql_string);
276
+                    if ($k[0] != ':') $k = ':' . $k; //add leading colon if it was left out
277
+                    $sql_string = str_replace($k, $v, $sql_string);
278 278
                 }
279 279
             }
280 280
         }
Please login to merge, or discard this patch.
src/Crud.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
     /**
98 98
      * @return string|null
99 99
      */
100
-    public function getLogSQL():?string
100
+    public function getLogSQL(): ?string
101 101
     {
102 102
         return $this->logSQL;
103 103
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,8 +63,9 @@  discard block
 block discarded – undo
63 63
             $query = "INSERT INTO $this->tableName";
64 64
             $values = [];
65 65
             $dataColumns = array_keys($params);
66
-            if (isset ($dataColumns[0]))
67
-                $query .= ' (`' . implode('`, `', $dataColumns) . '`) ';
66
+            if (isset ($dataColumns[0])) {
67
+                            $query .= ' (`' . implode('`, `', $dataColumns) . '`) ';
68
+            }
68 69
             $query .= ' VALUES (';
69 70
 
70 71
             foreach ($dataColumns as $index => $column) {
@@ -117,8 +118,9 @@  discard block
 block discarded – undo
117 118
             }
118 119
             $query = rtrim($query, ", ");
119 120
 
120
-            if (!empty($where))
121
-                $query .= " WHERE {$where}";
121
+            if (!empty($where)) {
122
+                            $query .= " WHERE {$where}";
123
+            }
122 124
 
123 125
             return $this->executeSQL($query, $values);
124 126
         } else {
Please login to merge, or discard this patch.
src/ModelAbstract.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     /**
10 10
      * @param array|null $params
11 11
      */
12
-    public function __construct(array $params = null){
12
+    public function __construct(array $params = null) {
13 13
         if (!empty($params))
14 14
             $this->modelFromMap($params);
15 15
     }
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
         $re_2 = new ReflectionObject($data);
75 75
         $classname = get_class($this);
76 76
         if ($pos = strrpos($classname, '\\')) $classname = substr($classname, $pos + 1);
77
-        return $classname .' {' . implode(', ', array_map(
77
+        return $classname . ' {' . implode(', ', array_map(
78 78
                 function($p_0) use ($data)
79 79
                 {
80 80
                     $p_0->setAccessible(true);
81
-                    return $p_0->getName() .': '. $p_0->getValue($data);
82
-                }, $re_2->getProperties())) .'}';
81
+                    return $p_0->getName() . ': ' . $p_0->getValue($data);
82
+                }, $re_2->getProperties())) . '}';
83 83
 
84 84
     }
85 85
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@  discard block
 block discarded – undo
10 10
      * @param array|null $params
11 11
      */
12 12
     public function __construct(array $params = null){
13
-        if (!empty($params))
14
-            $this->modelFromMap($params);
13
+        if (!empty($params)) {
14
+                    $this->modelFromMap($params);
15
+        }
15 16
     }
16 17
 
17 18
     /**
@@ -73,7 +74,9 @@  discard block
 block discarded – undo
73 74
         $data = (object) $this->toMap();
74 75
         $re_2 = new ReflectionObject($data);
75 76
         $classname = get_class($this);
76
-        if ($pos = strrpos($classname, '\\')) $classname = substr($classname, $pos + 1);
77
+        if ($pos = strrpos($classname, '\\')) {
78
+            $classname = substr($classname, $pos + 1);
79
+        }
77 80
         return $classname .' {' . implode(', ', array_map(
78 81
                 function($p_0) use ($data)
79 82
                 {
Please login to merge, or discard this patch.