Passed
Push — master ( 5500dc...c55c4a )
by y
01:27
created
src/DB/SQL/TextTrait.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     /**
18 18
      * @return Text
19 19
      */
20
-    public function getHex () {
20
+    public function getHex() {
21 21
         return new Text($this->db, "HEX({$this})");
22 22
     }
23 23
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      *
29 29
      * @return Numeric
30 30
      */
31
-    public function getLength () {
31
+    public function getLength() {
32 32
         switch ($this->db) {
33 33
             case 'sqlite':
34 34
                 return new Numeric($this->db, "LENGTH(CAST({$this} AS TEXT))");
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      *
43 43
      * @return Text
44 44
      */
45
-    public function getLower () {
45
+    public function getLower() {
46 46
         return new Text($this->db, "LOWER({$this})");
47 47
     }
48 48
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @param string $substring
55 55
      * @return Numeric
56 56
      */
57
-    public function getPosition (string $substring) {
57
+    public function getPosition(string $substring) {
58 58
         $substring = $this->db->quote($substring);
59 59
         switch ($this->db) {
60 60
             case 'sqlite':
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      * @param string $replace
72 72
      * @return Text
73 73
      */
74
-    public function getReplacement (string $search, string $replace) {
74
+    public function getReplacement(string $search, string $replace) {
75 75
         $search = $this->db->quote($search);
76 76
         $replace = $this->db->quote($replace);
77 77
         return new Text($this->db, "REPLACE({$this},{$search},{$replace})");
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @return Numeric
84 84
      */
85
-    public function getSize () {
85
+    public function getSize() {
86 86
         switch ($this->db) {
87 87
             case 'sqlite':
88 88
                 return new Numeric($this->db, "LENGTH(CAST({$this} AS BLOB))");
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * @param int $length
99 99
      * @return Text
100 100
      */
101
-    public function getSubstring (int $start, int $length = null) {
101
+    public function getSubstring(int $start, int $length = null) {
102 102
         if (isset($length)) {
103 103
             return new Text($this->db, "SUBSTR({$this},{$start},{$length})");
104 104
         }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @return Text
112 112
      */
113
-    public function getUpper () {
113
+    public function getUpper() {
114 114
         return new Text($this->db, "UPPER({$this})");
115 115
     }
116 116
 }
117 117
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/SQL/AggregateTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      * @param string $aggregate `ALL|DISTINCT`
21 21
      * @return Numeric
22 22
      */
23
-    public function getAvg ($aggregate = 'ALL') {
23
+    public function getAvg($aggregate = 'ALL') {
24 24
         return new Numeric($this->db, "AVG({$aggregate} {$this})");
25 25
     }
26 26
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      * @param string $delimiter
31 31
      * @return Text
32 32
      */
33
-    public function getConcat (string $delimiter = ',') {
33
+    public function getConcat(string $delimiter = ',') {
34 34
         $delimiter = $this->db->quote($delimiter);
35 35
         switch ($this->db) {
36 36
             case 'sqlite':
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param string $aggregate `ALL|DISTINCT`
47 47
      * @return Numeric
48 48
      */
49
-    public function getCount (string $aggregate = 'ALL') {
49
+    public function getCount(string $aggregate = 'ALL') {
50 50
         return new Numeric($this->db, "COUNT({$aggregate} {$this})");
51 51
     }
52 52
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return Numeric
57 57
      */
58
-    public function getMax () {
58
+    public function getMax() {
59 59
         return new Numeric($this->db, "MAX({$this})");
60 60
     }
61 61
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      *
65 65
      * @return Numeric
66 66
      */
67
-    public function getMin () {
67
+    public function getMin() {
68 68
         return new Numeric($this->db, "MIN({$this})");
69 69
     }
70 70
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param string $aggregate `ALL|DISTINCT`
75 75
      * @return Numeric
76 76
      */
77
-    public function getSum (string $aggregate = 'ALL') {
77
+    public function getSum(string $aggregate = 'ALL') {
78 78
         return new Numeric($this->db, "SUM({$aggregate} {$this})");
79 79
     }
80 80
 }
81 81
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/SQL/Numeric.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
      * @return Text
16 16
      */
17
-    public function toText () {
17
+    public function toText() {
18 18
         if ($this->db == 'sqlite') {
19 19
             return new Text($this->db, "CAST({$this} AS TEXT)");
20 20
         }
Please login to merge, or discard this patch.
src/DB/Select.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      * @param string|Select $table
104 104
      * @param string[] $columns
105 105
      */
106
-    public function __construct (DB $db, $table, array $columns) {
106
+    public function __construct(DB $db, $table, array $columns) {
107 107
         parent::__construct($db);
108 108
         if ($table instanceof Select) {
109 109
             $this->table = $table->toSubquery();
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      * @param array $args
124 124
      * @return Statement
125 125
      */
126
-    public function __invoke (array $args = []) {
126
+    public function __invoke(array $args = []) {
127 127
         return $this->execute($args);
128 128
     }
129 129
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      *
133 133
      * @return string
134 134
      */
135
-    final public function __toString () {
135
+    final public function __toString() {
136 136
         return $this->alias;
137 137
     }
138 138
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      * @param array $args Execution arguments.
143 143
      * @return int
144 144
      */
145
-    public function count (array $args = []): int {
145
+    public function count(array $args = []): int {
146 146
         $clone = clone $this;
147 147
         $clone->_columns = 'COUNT(*)';
148 148
         $clone->_order = '';
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      * @param array $args
156 156
      * @return Statement
157 157
      */
158
-    public function execute (array $args = []) {
158
+    public function execute(array $args = []) {
159 159
         if (empty($args)) {
160 160
             return $this->db->query($this->toSql());
161 161
         }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * @param array $args Execution arguments.
171 171
      * @return array
172 172
      */
173
-    public function getAll (array $args = []): array {
173
+    public function getAll(array $args = []): array {
174 174
         return iterator_to_array($this->fetcher->__invoke($this->execute($args)));
175 175
     }
176 176
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      * @param array $args Execution arguments.
184 184
      * @return Generator
185 185
      */
186
-    public function getEach (array $args = []) {
186
+    public function getEach(array $args = []) {
187 187
         yield from $this->fetcher->__invoke($this->execute($args));
188 188
     }
189 189
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      * @param array $args
196 196
      * @return mixed
197 197
      */
198
-    public function getFirst (array $args = []) {
198
+    public function getFirst(array $args = []) {
199 199
         return $this->getEach($args)->current();
200 200
     }
201 201
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
      *
207 207
      * @return Generator
208 208
      */
209
-    public function getIterator () {
209
+    public function getIterator() {
210 210
         yield from $this->getEach();
211 211
     }
212 212
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
      * @param string $column
217 217
      * @return $this
218 218
      */
219
-    public function group (string $column) {
219
+    public function group(string $column) {
220 220
         if (!strlen($this->_group)) {
221 221
             $this->_group = " GROUP BY {$column}";
222 222
         }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      * @param string $condition
233 233
      * @return $this
234 234
      */
235
-    public function having (string $condition) {
235
+    public function having(string $condition) {
236 236
         if (!strlen($this->_having)) {
237 237
             $this->_having = " HAVING {$condition}";
238 238
         }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      *
248 248
      * @return Predicate
249 249
      */
250
-    public function isCorrelated () {
250
+    public function isCorrelated() {
251 251
         return new Predicate("EXISTS ({$this->toSql()})");
252 252
     }
253 253
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      *
257 257
      * @return Predicate
258 258
      */
259
-    public function isNotCorrelated () {
259
+    public function isNotCorrelated() {
260 260
         return new Predicate("NOT EXISTS ({$this->toSql()})");
261 261
     }
262 262
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      * @param string $type
269 269
      * @return $this
270 270
      */
271
-    public function join ($table, string $condition, string $type = 'INNER') {
271
+    public function join($table, string $condition, string $type = 'INNER') {
272 272
         if ($table instanceof Select) {
273 273
             $table = $table->toSubquery();
274 274
         }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      * @param int $offset
284 284
      * @return $this
285 285
      */
286
-    public function limit (int $limit, int $offset = 0) {
286
+    public function limit(int $limit, int $offset = 0) {
287 287
         if ($limit == 0) {
288 288
             $this->_limit = '';
289 289
         }
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
      * @param mixed $offset Ordinal or reference name.
303 303
      * @return bool
304 304
      */
305
-    public function offsetExists ($offset): bool {
305
+    public function offsetExists($offset): bool {
306 306
         return isset($this->references[$offset]);
307 307
     }
308 308
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      * @param mixed $offset Ordinal or reference name.
313 313
      * @return Column
314 314
      */
315
-    public function offsetGet ($offset) {
315
+    public function offsetGet($offset) {
316 316
         return $this->references[$offset];
317 317
     }
318 318
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      * @param string $order
323 323
      * @return $this
324 324
      */
325
-    public function order (string $order) {
325
+    public function order(string $order) {
326 326
         if (strlen($order)) {
327 327
             $order = " ORDER BY {$order}";
328 328
         }
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     /**
334 334
      * @return Statement
335 335
      */
336
-    public function prepare () {
336
+    public function prepare() {
337 337
         return $this->db->prepare($this->toSql());
338 338
     }
339 339
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
      * @param string $alias
342 342
      * @return $this
343 343
      */
344
-    public function setAlias (string $alias) {
344
+    public function setAlias(string $alias) {
345 345
         $this->alias = $alias;
346 346
         return $this;
347 347
     }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
      * @param string[] $columns
351 351
      * @return $this
352 352
      */
353
-    public function setColumns (array $columns) {
353
+    public function setColumns(array $columns) {
354 354
         $this->references = [];
355 355
         $_columns = [];
356 356
         $i = 0;
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      * @param Closure $fetcher
381 381
      * @return $this
382 382
      */
383
-    public function setFetcher (Closure $fetcher) {
383
+    public function setFetcher(Closure $fetcher) {
384 384
         $this->fetcher = $fetcher;
385 385
         return $this;
386 386
     }
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
      *
391 391
      * @return string
392 392
      */
393
-    public function toSql (): string {
393
+    public function toSql(): string {
394 394
         $sql = "SELECT {$this->_columns} FROM {$this->table}";
395 395
         $sql .= $this->_join;
396 396
         $sql .= $this->_where;
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
      *
407 407
      * @return string
408 408
      */
409
-    public function toSubquery (): string {
409
+    public function toSubquery(): string {
410 410
         return "({$this->toSql()}) AS {$this->alias}";
411 411
     }
412 412
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
      * @param string $condition
417 417
      * @return $this
418 418
      */
419
-    public function where (string $condition) {
419
+    public function where(string $condition) {
420 420
         if (!strlen($this->_where)) {
421 421
             $this->_where = " WHERE {$condition}";
422 422
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -108,8 +108,7 @@  discard block
 block discarded – undo
108 108
         if ($table instanceof Select) {
109 109
             $this->table = $table->toSubquery();
110 110
             $this->alias = uniqid('_') . "_{$table->alias}";
111
-        }
112
-        else {
111
+        } else {
113 112
             $this->table = (string)$table;
114 113
             $this->alias = uniqid('_') . "__{$table}";
115 114
         }
@@ -219,8 +218,7 @@  discard block
 block discarded – undo
219 218
     public function group (string $column) {
220 219
         if (!strlen($this->_group)) {
221 220
             $this->_group = " GROUP BY {$column}";
222
-        }
223
-        else {
221
+        } else {
224 222
             $this->_group .= ", {$column}";
225 223
         }
226 224
         return $this;
@@ -235,8 +233,7 @@  discard block
 block discarded – undo
235 233
     public function having (string $condition) {
236 234
         if (!strlen($this->_having)) {
237 235
             $this->_having = " HAVING {$condition}";
238
-        }
239
-        else {
236
+        } else {
240 237
             $this->_having .= " AND {$condition}";
241 238
         }
242 239
         return $this;
@@ -286,8 +283,7 @@  discard block
 block discarded – undo
286 283
     public function limit (int $limit, int $offset = 0) {
287 284
         if ($limit == 0) {
288 285
             $this->_limit = '';
289
-        }
290
-        else {
286
+        } else {
291 287
             $this->_limit = " LIMIT {$limit}";
292 288
             if ($offset > 1) {
293 289
                 $this->_limit .= " OFFSET {$offset}";
@@ -366,8 +362,7 @@  discard block
 block discarded – undo
366 362
             }
367 363
             if ($name === $alias) {
368 364
                 $_columns[] = "{$column}";
369
-            }
370
-            else {
365
+            } else {
371 366
                 $_columns[] = "{$column} AS {$alias}";
372 367
             }
373 368
             $i++;
@@ -419,8 +414,7 @@  discard block
 block discarded – undo
419 414
     public function where (string $condition) {
420 415
         if (!strlen($this->_where)) {
421 416
             $this->_where = " WHERE {$condition}";
422
-        }
423
-        else {
417
+        } else {
424 418
             $this->_where .= " AND {$condition}";
425 419
         }
426 420
         return $this;
Please login to merge, or discard this patch.
src/DB/SQL/Predicate.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      * @param string[] $conditions
18 18
      * @return Predicate
19 19
      */
20
-    public static function all (array $conditions) {
20
+    public static function all(array $conditions) {
21 21
         if (count($conditions) === 1) {
22 22
             return reset($conditions);
23 23
         }
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      * @param string[] $conditions
31 31
      * @return Predicate
32 32
      */
33
-    public static function any (array $conditions) {
33
+    public static function any(array $conditions) {
34 34
         if (count($conditions) === 1) {
35 35
             return reset($conditions);
36 36
         }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      * @param string $multiOper
57 57
      * @return Predicate
58 58
      */
59
-    public static function compare ($a, $b, $oper = '=', $multiOper = 'IN') {
59
+    public static function compare($a, $b, $oper = '=', $multiOper = 'IN') {
60 60
         if (is_array($b)) {
61 61
             return new static("{$a} {$multiOper} (" . implode(',', $b) . ")");
62 62
         }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @param string $listOper
78 78
      * @return Predicate[]
79 79
      */
80
-    public static function compareArray (array $values, $oper = '=', $listOper = 'IN') {
80
+    public static function compareArray(array $values, $oper = '=', $listOper = 'IN') {
81 81
         foreach ($values as $a => $b) {
82 82
             $values[$a] = static::compare($a, $b, $oper, $listOper);
83 83
         }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      *
90 90
      * @return Predicate
91 91
      */
92
-    public function invert () {
92
+    public function invert() {
93 93
         return new static("NOT({$this})");
94 94
     }
95 95
 }
96 96
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,8 +59,7 @@
 block discarded – undo
59 59
     public static function compare ($a, $b, $oper = '=', $multiOper = 'IN') {
60 60
         if (is_array($b)) {
61 61
             return new static("{$a} {$multiOper} (" . implode(',', $b) . ")");
62
-        }
63
-        elseif ($b instanceof Select) {
62
+        } elseif ($b instanceof Select) {
64 63
             return new static("{$a} {$multiOper} ({$b->toSql()})");
65 64
         }
66 65
         return new static("{$a} {$oper} {$b}");
Please login to merge, or discard this patch.