Passed
Pull Request — master (#2)
by Maksim
02:00
created
src/BaseLookupCollection.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@
 block discarded – undo
106 106
 
107 107
             case 'in':
108 108
                 if (is_array($value)) {
109
-                    $quotedValues = array_map(function ($item) use ($adapter) {
109
+                    $quotedValues = array_map(function($item) use ($adapter) {
110 110
                         return $adapter->quoteValue($item);
111 111
                     }, $value);
112 112
                     $sqlValue = implode(', ', $quotedValues);
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,11 +39,14 @@  discard block
 block discarded – undo
39 39
 
40 40
                 if ($value instanceof Expression) {
41 41
                     $sqlValue = $value->toSQL();
42
-                } else if ($value instanceof QueryBuilder) {
42
+                }
43
+                else if ($value instanceof QueryBuilder) {
43 44
                     $sqlValue = '(' . $value->toSQL() . ')';
44
-                } else if (strpos($value, 'SELECT') !== false) {
45
+                }
46
+                else if (strpos($value, 'SELECT') !== false) {
45 47
                     $sqlValue = '(' . $value . ')';
46
-                } else {
48
+                }
49
+                else {
47 50
                     $sqlValue = $adapter->quoteValue($value);
48 51
                 }
49 52
                 return $adapter->quoteColumn($column) . '=' . $sqlValue;
@@ -110,9 +113,11 @@  discard block
 block discarded – undo
110 113
                         return $adapter->quoteValue($item);
111 114
                     }, $value);
112 115
                     $sqlValue = implode(', ', $quotedValues);
113
-                } else if ($value instanceof QueryBuilder) {
116
+                }
117
+                else if ($value instanceof QueryBuilder) {
114 118
                     $sqlValue = $value->toSQL();
115
-                } else {
119
+                }
120
+                else {
116 121
                     $sqlValue = $adapter->quoteSql($value);
117 122
                 }
118 123
                 return $adapter->quoteColumn($column) . ' IN (' . $sqlValue . ')';
Please login to merge, or discard this patch.
src/BaseAdapter.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     public function setDriver($driver)
109 109
     {
110 110
         if (!($driver instanceof \PDO || $driver instanceof Connection)) {
111
-            throw new QBException('Drive must be instance PDO or '. Connection::class);
111
+            throw new QBException('Drive must be instance PDO or ' . Connection::class);
112 112
         }
113 113
 
114 114
         $this->driver = $driver;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
                 $values[] = '(' . implode(', ', $record) . ')';
341 341
             }
342 342
 
343
-            $sql = 'INSERT'. $options .' INTO ' . $this->quoteTableName($tableName) . ' (' . implode(', ', $columns) . ') VALUES ' . implode(', ', $values);
343
+            $sql = 'INSERT' . $options . ' INTO ' . $this->quoteTableName($tableName) . ' (' . implode(', ', $columns) . ') VALUES ' . implode(', ', $values);
344 344
 
345 345
             return $this->quoteSql($sql);
346 346
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
         $values = array_map([$this, 'quoteValue'], $rows);
349 349
         $columns = array_map([$this, 'quoteColumn'], array_keys($rows));
350 350
 
351
-        $sql = 'INSERT'. $options .' INTO ' . $this->quoteTableName($tableName) . ' (' . implode(', ', $columns) . ') VALUES (' . implode(', ', $values) . ')';
351
+        $sql = 'INSERT' . $options . ' INTO ' . $this->quoteTableName($tableName) . ' (' . implode(', ', $columns) . ') VALUES (' . implode(', ', $values) . ')';
352 352
 
353 353
         return $this->quoteSql($sql);
354 354
     }
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
             $options = " {$options} ";
365 365
         }
366 366
 
367
-        return 'UPDATE '. $options . $this->quoteTableName($tableName) . ' SET ' . implode(', ', $parts);
367
+        return 'UPDATE ' . $options . $this->quoteTableName($tableName) . ' SET ' . implode(', ', $parts);
368 368
     }
369 369
 
370 370
     /**
@@ -629,12 +629,12 @@  discard block
 block discarded – undo
629 629
         $toSql = [$joinType];
630 630
         if (is_string($tableName) && $tableName = $this->getRawTableName($tableName)) {
631 631
             if (strpos($tableName, 'SELECT') !== false) {
632
-                $toSql[] = '(' . $this->quoteSql($tableName) . ')' ;
632
+                $toSql[] = '(' . $this->quoteSql($tableName) . ')';
633 633
             } else {
634
-                $toSql[]  = $this->quoteTableName($tableName);
634
+                $toSql[] = $this->quoteTableName($tableName);
635 635
             }
636 636
         } else if ($tableName instanceof QueryBuilder) {
637
-            $toSql[] =  '(' . $this->quoteSql($tableName->toSQL()) . ')' ;
637
+            $toSql[] = '(' . $this->quoteSql($tableName->toSQL()) . ')';
638 638
         } else {
639 639
             throw new QBException('Incorrect table name');
640 640
         }
Please login to merge, or discard this patch.
Braces   +42 added lines, -21 removed lines patch added patch discarded remove patch
@@ -56,7 +56,8 @@  discard block
 block discarded – undo
56 56
         if (($pos = strrpos($name, '.')) !== false) {
57 57
             $prefix = $this->quoteTableName(substr($name, 0, $pos)) . '.';
58 58
             $name = substr($name, $pos + 1);
59
-        } else {
59
+        }
60
+        else {
60 61
             $prefix = '';
61 62
         }
62 63
         return $prefix . $this->quoteSimpleColumnName($name);
@@ -134,13 +135,17 @@  discard block
 block discarded – undo
134 135
     {
135 136
         if ($value instanceof IToSql) {
136 137
             return $value->toSql();
137
-        } else if ($value === true || strtolower($value) === 'true') {
138
+        }
139
+        else if ($value === true || strtolower($value) === 'true') {
138 140
             return 'TRUE';
139
-        } else if ($value === false || strtolower($value) === 'false') {
141
+        }
142
+        else if ($value === false || strtolower($value) === 'false') {
140 143
             return 'FALSE';
141
-        } else if ($value === null || strtolower($value) === 'null') {
144
+        }
145
+        else if ($value === null || strtolower($value) === 'null') {
142 146
             return 'NULL';
143
-        } else if (is_string($value) && $driver = $this->getDriver()) {
147
+        }
148
+        else if (is_string($value) && $driver = $this->getDriver()) {
144 149
             return $driver->quote($value);
145 150
         }
146 151
 
@@ -213,7 +218,8 @@  discard block
 block discarded – undo
213 218
     {
214 219
         if ($rawValue === true || $rawValue === false || $rawValue === 'true' || $rawValue === 'false') {
215 220
             return $this->getBoolean($rawValue);
216
-        } else if ($rawValue === 'null' || $rawValue === null) {
221
+        }
222
+        else if ($rawValue === 'null' || $rawValue === null) {
217 223
             return 'NULL';
218 224
         }
219 225
         return $rawValue;
@@ -267,7 +273,8 @@  discard block
 block discarded – undo
267 273
         foreach ($columns as $i => $column) {
268 274
             if ($column instanceof Expression) {
269 275
                 $columns[$i] = $column->toSQL();
270
-            } else if (strpos($column, '(') === false) {
276
+            }
277
+            else if (strpos($column, '(') === false) {
271 278
                 $columns[$i] = $this->quoteColumn($column);
272 279
             }
273 280
         }
@@ -417,12 +424,14 @@  discard block
 block discarded – undo
417 424
             foreach ($columns as $name => $type) {
418 425
                 if (is_string($name)) {
419 426
                     $cols[] = "\t" . $this->quoteColumn($name) . ' ' . $type;
420
-                } else {
427
+                }
428
+                else {
421 429
                     $cols[] = "\t" . $type;
422 430
                 }
423 431
             }
424 432
             $sql = ($ifNotExists ? "CREATE TABLE IF NOT EXISTS " : "CREATE TABLE ") . $this->quoteTableName($tableName) . " (\n" . implode(",\n", $cols) . "\n)";
425
-        } else {
433
+        }
434
+        else {
426 435
             $sql = ($ifNotExists ? "CREATE TABLE IF NOT EXISTS " : "CREATE TABLE ") . $this->quoteTableName($tableName) . " " . $this->quoteSql($columns);
427 436
         }
428 437
         return empty($options) ? $sql : $sql . ' ' . $options;
@@ -472,11 +481,14 @@  discard block
 block discarded – undo
472 481
     {
473 482
         if ($value === 'true' || $value === true) {
474 483
             return 'TRUE';
475
-        } else if ($value === null || $value === 'null') {
484
+        }
485
+        else if ($value === null || $value === 'null') {
476 486
             return 'NULL';
477
-        } else if ($value === false || $value === 'false') {
487
+        }
488
+        else if ($value === false || $value === 'false') {
478 489
             return 'FALSE';
479
-        } else {
490
+        }
491
+        else {
480 492
             return $value;
481 493
         }
482 494
     }
@@ -604,12 +616,14 @@  discard block
 block discarded – undo
604 616
         foreach ($tables as $tableAlias => $table) {
605 617
             if ($table instanceof QueryBuilder) {
606 618
                 $tableRaw = $table->toSQL();
607
-            } else {
619
+            }
620
+            else {
608 621
                 $tableRaw = $this->getRawTableName($table);
609 622
             }
610 623
             if (strpos($tableRaw, 'SELECT') !== false) {
611 624
                 $quotedTableNames[] = '(' . $tableRaw . ')' . (is_numeric($tableAlias) ? '' : ' AS ' . $this->quoteTableName($tableAlias));
612
-            } else {
625
+            }
626
+            else {
613 627
                 $quotedTableNames[] = $this->quoteTableName($tableRaw) . (is_numeric($tableAlias) ? '' : ' AS ' . $this->quoteTableName($tableAlias));
614 628
             }
615 629
         }
@@ -630,12 +644,15 @@  discard block
 block discarded – undo
630 644
         if (is_string($tableName) && $tableName = $this->getRawTableName($tableName)) {
631 645
             if (strpos($tableName, 'SELECT') !== false) {
632 646
                 $toSql[] = '(' . $this->quoteSql($tableName) . ')' ;
633
-            } else {
647
+            }
648
+            else {
634 649
                 $toSql[]  = $this->quoteTableName($tableName);
635 650
             }
636
-        } else if ($tableName instanceof QueryBuilder) {
651
+        }
652
+        else if ($tableName instanceof QueryBuilder) {
637 653
             $toSql[] =  '(' . $this->quoteSql($tableName->toSQL()) . ')' ;
638
-        } else {
654
+        }
655
+        else {
639 656
             throw new QBException('Incorrect table name');
640 657
         }
641 658
 
@@ -647,11 +664,13 @@  discard block
 block discarded – undo
647 664
             $onSQL = [];
648 665
             if (is_string($on)) {
649 666
                 $onSQL[] = $this->quoteSql($on);
650
-            } else {
667
+            }
668
+            else {
651 669
                 foreach ($on as $leftColumn => $rightColumn) {
652 670
                     if ($rightColumn instanceof Expression) {
653 671
                         $onSQL[] = $this->quoteColumn($leftColumn) . '=' . $this->quoteSql($rightColumn->toSQL());
654
-                    } else {
672
+                    }
673
+                    else {
655 674
                         $onSQL[] = $this->quoteColumn($leftColumn) . '=' . $this->quoteColumn($rightColumn);
656 675
                     }
657 676
                 }
@@ -689,7 +708,8 @@  discard block
 block discarded – undo
689 708
         if ($having instanceof IToSql) {
690 709
             $sql = $having
691 710
                 ->toSql();
692
-        } else {
711
+        }
712
+        else {
693 713
             $sql = $this->quoteSql($having);
694 714
         }
695 715
 
@@ -709,7 +729,8 @@  discard block
 block discarded – undo
709 729
 
710 730
         if ($union instanceof QueryBuilderInterface) {
711 731
             $unionSQL = $union->setOrder(null)->toSQL();
712
-        } else {
732
+        }
733
+        else {
713 734
             $unionSQL = $this->quoteSql($union);
714 735
         }
715 736
 
Please login to merge, or discard this patch.
src/Expression/Expression.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,10 +50,10 @@
 block discarded – undo
50 50
         if (strpos($sql, '?'))
51 51
         {
52 52
             if (mb_substr_count($sql, '?') !== count($this->params)) {
53
-                throw new QBException('Incorrect parameters count in Expression: "'.addslashes($this->expression).'"');
53
+                throw new QBException('Incorrect parameters count in Expression: "' . addslashes($this->expression) . '"');
54 54
             }
55 55
 
56
-            $sql = preg_replace_callback('~\?~', function ($matches) {
56
+            $sql = preg_replace_callback('~\?~', function($matches) {
57 57
                 return $this->qb->getAdapter()->quoteValue(
58 58
                     $this->getNextParam()
59 59
                 );
Please login to merge, or discard this patch.
src/ConnectionManager.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,8 @@
 block discarded – undo
50 50
         foreach ($config as $key => $value) {
51 51
             if (method_exists($this, 'set' . ucfirst($key))) {
52 52
                 $this->{'set' . ucfirst($key)}($value);
53
-            } else {
53
+            }
54
+            else {
54 55
                 $this->{$key} = $value;
55 56
             }
56 57
         }
Please login to merge, or discard this patch.
src/Database/Pgsql/LookupCollection.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@
 block discarded – undo
15 15
         ];
16 16
         if (in_array($lookup, $lookups)) {
17 17
             return true;
18
-        } else {
18
+        }
19
+        else {
19 20
             return parent::has($lookup);
20 21
         }
21 22
     }
Please login to merge, or discard this patch.
src/Database/Pgsql/Adapter.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -193,11 +193,14 @@
 block discarded – undo
193 193
     {
194 194
         if ($value instanceof \DateTime) {
195 195
             $value = $value->format($format);
196
-        } elseif ($value === null) {
196
+        }
197
+        elseif ($value === null) {
197 198
             $value = date($format);
198
-        } elseif (is_numeric($value)) {
199
+        }
200
+        elseif (is_numeric($value)) {
199 201
             $value = date($format, $value);
200
-        } elseif (is_string($value)) {
202
+        }
203
+        elseif (is_string($value)) {
201 204
             $value = date($format, strtotime($value));
202 205
         }
203 206
         return $value;
Please login to merge, or discard this patch.
src/Database/Mysql/Adapter.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -92,7 +92,8 @@  discard block
 block discarded – undo
92 92
     {
93 93
         if (gettype($value) === 'boolean') {
94 94
             return (int)$value;
95
-        } else {
95
+        }
96
+        else {
96 97
             return $value ? 1 : 0;
97 98
         }
98 99
     }
@@ -101,11 +102,14 @@  discard block
 block discarded – undo
101 102
     {
102 103
         if ($value instanceof \DateTime) {
103 104
             $value = $value->format($format);
104
-        } elseif ($value === null) {
105
+        }
106
+        elseif ($value === null) {
105 107
             $value = date($format);
106
-        } elseif (is_numeric($value)) {
108
+        }
109
+        elseif (is_numeric($value)) {
107 110
             $value = date($format, $value);
108
-        } elseif (is_string($value)) {
111
+        }
112
+        elseif (is_string($value)) {
109 113
             $value = date($format, strtotime($value));
110 114
         }
111 115
         return $value;
@@ -170,7 +174,8 @@  discard block
 block discarded – undo
170 174
                 $sql .= ' OFFSET ' . $offset;
171 175
             }
172 176
             return ' ' . $sql;
173
-        } elseif ($this->hasOffset($offset)) {
177
+        }
178
+        elseif ($this->hasOffset($offset)) {
174 179
             // limit is not optional in MySQL
175 180
             // http://stackoverflow.com/a/271650/1106908
176 181
             // http://dev.mysql.com/doc/refman/5.0/en/select.html#idm47619502796240
@@ -196,7 +201,8 @@  discard block
 block discarded – undo
196 201
         }
197 202
         if (isset($row['Create Table'])) {
198 203
             $sql = $row['Create Table'];
199
-        } else {
204
+        }
205
+        else {
200 206
             $row = array_values($row);
201 207
             $sql = $row[1];
202 208
         }
Please login to merge, or discard this patch.
src/Database/Sqlite/Adapter.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -178,11 +178,14 @@  discard block
 block discarded – undo
178 178
     {
179 179
         if ($value instanceof \DateTime) {
180 180
             $value = $value->format($format);
181
-        } elseif ($value === null) {
181
+        }
182
+        elseif ($value === null) {
182 183
             $value = date($format);
183
-        } elseif (is_numeric($value)) {
184
+        }
185
+        elseif (is_numeric($value)) {
184 186
             $value = date($format, $value);
185
-        } elseif (is_string($value)) {
187
+        }
188
+        elseif (is_string($value)) {
186 189
             $value = date($format, strtotime($value));
187 190
         }
188 191
         return (string)$value;
@@ -219,7 +222,8 @@  discard block
 block discarded – undo
219 222
                 $sql .= ' OFFSET ' . $offset;
220 223
             }
221 224
             return ' ' . $sql;
222
-        } elseif ($this->hasOffset($offset)) {
225
+        }
226
+        elseif ($this->hasOffset($offset)) {
223 227
             // limit is not optional in SQLite
224 228
             // http://www.sqlite.org/syntaxdiagrams.html#select-stmt
225 229
             // If the LIMIT expression evaluates to a negative value, then there
Please login to merge, or discard this patch.
src/Database/Sqlite/LookupCollection.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@
 block discarded – undo
15 15
         ];
16 16
         if (in_array($lookup, $lookups)) {
17 17
             return true;
18
-        } else {
18
+        }
19
+        else {
19 20
             return parent::has($lookup);
20 21
         }
21 22
     }
Please login to merge, or discard this patch.