Passed
Push — main ( d5a765...5aef95 )
by BRUNO
02:41
created
example/ExampleDao.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
     public function findName(): array {
16 16
         $this->selectBuilder()
17
-            ->where("NOME=?",["Joao"])
17
+            ->where("NOME=?", ["Joao"])
18 18
             ->orderBy("NOME")
19 19
             ->executeQuery()
20 20
             ->fetchArrayAssoc();
Please login to merge, or discard this patch.
src/DatalayerTrait.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -161,8 +161,9 @@
 block discarded – undo
161 161
      */
162 162
     protected function setTableName(string $tableName, string $tableAlias = ""): self
163 163
     {
164
-        if (!empty($tableAlias))
165
-            $this->tableAlias = $tableAlias;
164
+        if (!empty($tableAlias)) {
165
+                    $this->tableAlias = $tableAlias;
166
+        }
166 167
         $this->tableName = $tableName;
167 168
         return $this;
168 169
     }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     {
76 76
         try {
77 77
             if (strpos($_SERVER['SERVER_NAME'], mb_strtolower(CONFIG_DATA_LAYER["homologation"])) && !strpos($this->getDatabase(), ucfirst(CONFIG_DATA_LAYER["homologation"]))) {
78
-                $database = $this->getDatabase().ucfirst(CONFIG_DATA_LAYER["homologation"] ?? "");
78
+                $database = $this->getDatabase() . ucfirst(CONFIG_DATA_LAYER["homologation"] ?? "");
79 79
                 $this->setDatabase($database);
80 80
             }
81 81
 
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
     protected function setDatabase(string $database): self
126 126
     {
127 127
         if (strpos($_SERVER['SERVER_NAME'], mb_strtolower(CONFIG_DATA_LAYER["homologation"])) && !strpos($database, ucfirst(CONFIG_DATA_LAYER["homologation"]))) {
128
-            $database = $database.ucfirst(CONFIG_DATA_LAYER["homologation"] ?? "");
128
+            $database = $database . ucfirst(CONFIG_DATA_LAYER["homologation"] ?? "");
129 129
             $this->database = $database;
130 130
         } else {
131 131
             $this->database = $database;
132 132
         }
133 133
 
134
-        if (!empty($this->instance)){
134
+        if (!empty($this->instance)) {
135 135
             $this->executeSQL("USE {$this->getDatabase()}");
136 136
         }
137 137
 
Please login to merge, or discard this patch.
rector.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 use Rector\Config\RectorConfig;
7 7
 use Rector\Set\ValueObject\LevelSetList;
8 8
 
9
-return static function (RectorConfig $rectorConfig): void {
9
+return static function(RectorConfig $rectorConfig): void {
10 10
     $rectorConfig->paths([
11 11
         __DIR__ . '/example',
12 12
         __DIR__ . '/src',
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
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
     public function select(string $fields = '*', string $add = '', ?array $values = null, bool $returnModel = false, bool $debug = false)
31 31
     {
32 32
         try {
33
-            if (strlen($add) > 0) {
33
+            if (strlen($add)>0) {
34 34
                 $add = ' ' . $add;
35 35
             }
36 36
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,9 @@
 block discarded – undo
37 37
 
38 38
             $sql = "SELECT {$fields} FROM {$this->getTableName()}";
39 39
 
40
-            if (!empty($this->getTableAlias()))
41
-                $sql .= " AS {$this->getTableAlias()}";
40
+            if (!empty($this->getTableAlias())) {
41
+                            $sql .= " AS {$this->getTableAlias()}";
42
+            }
42 43
 
43 44
             $sql .= $add;
44 45
 
Please login to merge, or discard this patch.
src/CrudBuilder.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     protected function orderBy(string $parameter, ?string $order = null): self
229 229
     {
230 230
         try {
231
-            $query = "ORDER BY {$parameter} ".($order ?? 'ASC');
231
+            $query = "ORDER BY {$parameter} " . ($order ?? 'ASC');
232 232
             $this->add($query, "orderBy");
233 233
             return $this;
234 234
         } catch (\PDOException $e) {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     protected function addOrderBy(string $parameter, ?string $order = null): self
250 250
     {
251 251
         try {
252
-            $query = ", {$parameter} ".($order ?? 'ASC')." ";
252
+            $query = ", {$parameter} " . ($order ?? 'ASC') . " ";
253 253
             $this->add($query, "addOrderBy");
254 254
             return $this;
255 255
         } catch (\PDOException $e) {
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     protected function limit(string $texto): self
269 269
     {
270 270
         $query = "LIMIT {$texto}";
271
-        $this->add($query,"limit");
271
+        $this->add($query, "limit");
272 272
         return $this;
273 273
     }
274 274
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     {
282 282
         try {
283 283
             $query = "OFFSET {$texto}";
284
-            $this->add($query,"offset");
284
+            $this->add($query, "offset");
285 285
             return $this;
286 286
         } catch (\PDOException $e) {
287 287
             throw new DatabaseException(
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
     {
302 302
         try {
303 303
             $query = "GROUP BY {$texto}";
304
-            $this->add($query,"groupBy");
304
+            $this->add($query, "groupBy");
305 305
             return $this;
306 306
         } catch (\PDOException $e) {
307 307
             throw new DatabaseException(
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     {
322 322
         try {
323 323
             $query = "HAVING {$texto}";
324
-            $this->add($query,"having");
324
+            $this->add($query, "having");
325 325
             return $this;
326 326
         } catch (\PDOException $e) {
327 327
             throw new DatabaseException(
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
     {
342 342
         try {
343 343
             $query = "AND {$texto}";
344
-            $this->add($query,"andHaving");
344
+            $this->add($query, "andHaving");
345 345
             return $this;
346 346
         } catch (\PDOException $e) {
347 347
             throw new DatabaseException(
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
     {
362 362
         try {
363 363
             $query = "OR {$codition}";
364
-            $this->add($query,"orHaving");
364
+            $this->add($query, "orHaving");
365 365
             return $this;
366 366
         } catch (\PDOException $e) {
367 367
             throw new DatabaseException(
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
     {
384 384
         try {
385 385
             $query = "INNER JOIN {$table} AS {$alias} ON $codition";
386
-            $this->add($query,"join");
386
+            $this->add($query, "join");
387 387
             return $this;
388 388
         } catch (\PDOException $e) {
389 389
             throw new DatabaseException(
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
     {
406 406
         try {
407 407
             $query = "LEFT JOIN {$table} AS {$alias} ON {$codition}";
408
-            $this->add($query,"join");
408
+            $this->add($query, "join");
409 409
             return $this;
410 410
         } catch (\PDOException $e) {
411 411
             throw new DatabaseException(
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
     {
428 428
         try {
429 429
             $query = "RIGHT JOIN {$table} AS {$alias} ON $codition";
430
-            $this->add($query,"join");
430
+            $this->add($query, "join");
431 431
             return $this;
432 432
         } catch (\PDOException $e) {
433 433
             throw new DatabaseException(
@@ -445,13 +445,13 @@  discard block
 block discarded – undo
445 445
     protected function executeQuery(): self
446 446
     {
447 447
         try {
448
-            foreach ($this->sqlPartsSelect as $key => $part){
448
+            foreach ($this->sqlPartsSelect as $key => $part) {
449 449
                 if (is_array($part)) {
450
-                    foreach ($part as $item){
451
-                        $this->setQuery($this->getQuery().$item);
450
+                    foreach ($part as $item) {
451
+                        $this->setQuery($this->getQuery() . $item);
452 452
                     }
453 453
                 } else {
454
-                    $this->setQuery($this->getQuery().$part);
454
+                    $this->setQuery($this->getQuery() . $part);
455 455
                 }
456 456
 
457 457
             }
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
      */
497 497
     private function add(string $query, string $type, array $params = []): void
498 498
     {
499
-        $query = $query." ";
499
+        $query = $query . " ";
500 500
         try {
501 501
             if (is_array($this->sqlPartsSelect[$type])) {
502 502
                 $this->sqlPartsSelect[$type][] = $query;
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
     {
49 49
         try {
50 50
             $query = "SELECT {$fields} FROM {$this->getTableName()}";
51
-            if (!empty($this->getTableAlias()))
52
-                $query .= " AS {$this->getTableAlias()}";
51
+            if (!empty($this->getTableAlias())) {
52
+                            $query .= " AS {$this->getTableAlias()}";
53
+            }
53 54
             $this->add($query, "main", $paramns);
54 55
             return $this;
55 56
         } catch (\PDOException $e) {
@@ -504,8 +505,9 @@  discard block
 block discarded – undo
504 505
                 $this->sqlPartsSelect[$type] = $query;
505 506
             }
506 507
 
507
-            if (!empty($params))
508
-                $this->setParams($params);
508
+            if (!empty($params)) {
509
+                            $this->setParams($params);
510
+            }
509 511
         } catch (\PDOException $e) {
510 512
             throw new DatabaseException(
511 513
                 "Add query part failed - TABLE: [{$this->getTableName()}] MESSAGE: [{$e->getMessage()}]",
Please login to merge, or discard this patch.
src/DatabaseException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 
20 20
     public function __construct(
21 21
         string $message,
22
-        int|string $code = 0,  // ✅ Aceita int ou string
22
+        int | string $code = 0, // ✅ Aceita int ou string
23 23
         ?Throwable $previous = null,
24 24
         ?string $query = null,
25 25
         ?array $parameters = null
26 26
     ) {
27 27
         // ✅ Converte string para int de forma segura
28
-        $intCode = is_string($code) ? (int)$code : $code;
28
+        $intCode = is_string($code) ? (int) $code : $code;
29 29
         if ($intCode === 0 && is_string($code) && !empty($code)) {
30 30
             // Se a conversão resultou em 0 mas o código original não era vazio,
31 31
             // usa um código padrão
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     /**
62 62
      * Get original PDO error code (may be string)
63 63
      */
64
-    public function getOriginalCode(): int|string
64
+    public function getOriginalCode(): int | string
65 65
     {
66 66
         $previous = $this->getPrevious();
67 67
         return $previous ? $previous->getCode() : $this->getCode();
Please login to merge, or discard this patch.