Completed
Pull Request — master (#2)
by Maksim
04:01
created
src/BaseLookupCollection.php 1 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/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/BaseAdapter.php 1 patch
Braces   +42 added lines, -21 removed lines patch added patch discarded remove patch
@@ -55,7 +55,8 @@  discard block
 block discarded – undo
55 55
         if (($pos = strrpos($name, '.')) !== false) {
56 56
             $prefix = $this->quoteTableName(substr($name, 0, $pos)) . '.';
57 57
             $name = substr($name, $pos + 1);
58
-        } else {
58
+        }
59
+        else {
59 60
             $prefix = '';
60 61
         }
61 62
         return $prefix . $this->quoteSimpleColumnName($name);
@@ -133,13 +134,17 @@  discard block
 block discarded – undo
133 134
     {
134 135
         if ($value instanceof IToSql) {
135 136
             return $value->toSql();
136
-        } else if ($value === true || strtolower($value) === 'true') {
137
+        }
138
+        else if ($value === true || strtolower($value) === 'true') {
137 139
             return 'TRUE';
138
-        } else if ($value === false || strtolower($value) === 'false') {
140
+        }
141
+        else if ($value === false || strtolower($value) === 'false') {
139 142
             return 'FALSE';
140
-        } else if ($value === null || strtolower($value) === 'null') {
143
+        }
144
+        else if ($value === null || strtolower($value) === 'null') {
141 145
             return 'NULL';
142
-        } else if (is_string($value) && $driver = $this->getDriver()) {
146
+        }
147
+        else if (is_string($value) && $driver = $this->getDriver()) {
143 148
             return $driver->quote($value);
144 149
         }
145 150
 
@@ -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
                 }
@@ -691,7 +710,8 @@  discard block
 block discarded – undo
691 710
             $sql = $having
692 711
                 ->setQb($queryBuilder)
693 712
                 ->toSql();
694
-        } else {
713
+        }
714
+        else {
695 715
             $sql = $this->quoteSql($having);
696 716
         }
697 717
 
@@ -711,7 +731,8 @@  discard block
 block discarded – undo
711 731
 
712 732
         if ($union instanceof QueryBuilder) {
713 733
             $unionSQL = $union->setOrder(null)->toSQL();
714
-        } else {
734
+        }
735
+        else {
715 736
             $unionSQL = $this->quoteSql($union);
716 737
         }
717 738
         return ($all ? 'UNION ALL' : 'UNION') . ' (' . $unionSQL . ')';
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.
src/Database/Mysql/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.