@@ -34,43 +34,43 @@ discard block |
||
34 | 34 | |
35 | 35 | $query .= $Column->type; |
36 | 36 | |
37 | - if(isset($Column->length)) { |
|
37 | + if (isset($Column->length)) { |
|
38 | 38 | $query .= "(".$Column->length; |
39 | 39 | } |
40 | 40 | |
41 | - if(isset($Column->scale) && isset($Column->length)) { |
|
41 | + if (isset($Column->scale) && isset($Column->length)) { |
|
42 | 42 | $query .= ", ".$Column->scale.")"; |
43 | 43 | } else { |
44 | - if(isset($Column->length)) { |
|
44 | + if (isset($Column->length)) { |
|
45 | 45 | $query .= ")"; |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - if($Column->isUnsigned) { |
|
49 | + if ($Column->isUnsigned) { |
|
50 | 50 | $query .= " UNSIGNED"; |
51 | 51 | } |
52 | 52 | |
53 | - if($Column->notNull) { |
|
53 | + if ($Column->notNull) { |
|
54 | 54 | $query .= " NOT NULL"; |
55 | 55 | } |
56 | 56 | |
57 | - if($Column->isAutoIncrement) { |
|
57 | + if ($Column->isAutoIncrement) { |
|
58 | 58 | $query .= " AUTO_INCREMENT"; |
59 | 59 | } |
60 | 60 | |
61 | - if($Column->primaryKey) { |
|
61 | + if ($Column->primaryKey) { |
|
62 | 62 | $query .= " PRIMARY KEY"; |
63 | 63 | } |
64 | 64 | |
65 | - if($Column->foreignKey) { |
|
65 | + if ($Column->foreignKey) { |
|
66 | 66 | $query .= " FOREIGN KEY"; |
67 | 67 | } |
68 | 68 | |
69 | - if($Column->unique) { |
|
69 | + if ($Column->unique) { |
|
70 | 70 | $query .= " UNIQUE"; |
71 | 71 | } |
72 | 72 | |
73 | - if($Column->default != null) { |
|
73 | + if ($Column->default != null) { |
|
74 | 74 | $default = $Column->default; |
75 | 75 | if (is_string($default)) { |
76 | 76 | if (str($default)->startsWith("%")) |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $query .= " DEFAULT ".$default; |
83 | 83 | } |
84 | 84 | |
85 | - if(count($table->getColumns())-1 != $key) |
|
85 | + if (count($table->getColumns()) - 1 != $key) |
|
86 | 86 | $query .= ", "; |
87 | 87 | } |
88 | 88 | $query .= ");"; |
@@ -73,17 +73,19 @@ |
||
73 | 73 | if($Column->default != null) { |
74 | 74 | $default = $Column->default; |
75 | 75 | if (is_string($default)) { |
76 | - if (str($default)->startsWith("%")) |
|
77 | - $default = str($default)->explode("%")->last(); |
|
78 | - else |
|
79 | - $default = "'".$default."'"; |
|
76 | + if (str($default)->startsWith("%")) { |
|
77 | + $default = str($default)->explode("%")->last(); |
|
78 | + } else { |
|
79 | + $default = "'".$default."'"; |
|
80 | + } |
|
80 | 81 | } |
81 | 82 | |
82 | 83 | $query .= " DEFAULT ".$default; |
83 | 84 | } |
84 | 85 | |
85 | - if(count($table->getColumns())-1 != $key) |
|
86 | - $query .= ", "; |
|
86 | + if(count($table->getColumns())-1 != $key) { |
|
87 | + $query .= ", "; |
|
88 | + } |
|
87 | 89 | } |
88 | 90 | $query .= ");"; |
89 | 91 |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $original = $query->columns; |
55 | 55 | |
56 | 56 | if (is_null($query->columns)) { |
57 | - $query->columns = ['*']; |
|
57 | + $query->columns = [ '*' ]; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // To compile the query, we'll spin through each component of the query and |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | // basic routine regardless of an amount of records given to us to insert. |
96 | 96 | $table = $this->wrapTable($query->from); |
97 | 97 | |
98 | - if (! is_array(reset($values))) { |
|
99 | - $values = [$values]; |
|
98 | + if (!is_array(reset($values))) { |
|
99 | + $values = [ $values ]; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $columns = $this->columnize(array_keys(reset($values))); |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | // We need to build a list of parameter place-holders of values that are bound |
105 | 105 | // to the query. Each insert should have the exact same amount of parameter |
106 | 106 | // bindings so we will loop through the record and parameterize them all. |
107 | - $parameters = []; |
|
107 | + $parameters = [ ]; |
|
108 | 108 | |
109 | 109 | foreach ($values as $record) { |
110 | - $parameters[] = '('.$this->parameterize($record).')'; |
|
110 | + $parameters[ ] = '('.$this->parameterize($record).')'; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $parameters = implode(', ', $parameters); |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | // Each one of the columns in the update statements needs to be wrapped in the |
130 | 130 | // keyword identifiers, also a place-holder needs to be created for each of |
131 | 131 | // the values in the list of bindings so we can make the sets statements. |
132 | - $columns = []; |
|
132 | + $columns = [ ]; |
|
133 | 133 | |
134 | 134 | foreach ($values as $key => $value) { |
135 | 135 | $param = $this->parameter($value); |
136 | 136 | $param = is_string($param) ? "'".$param."'" : $param; |
137 | 137 | |
138 | - $columns[] = $this->wrap($key)." = ".$param; |
|
138 | + $columns[ ] = $this->wrap($key)." = ".$param; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | $columns = implode(', ', $columns); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function compileTruncate(Builder $query) |
173 | 173 | { |
174 | - return ['truncate '.$this->wrapTable($query->from) => []]; |
|
174 | + return [ 'truncate '.$this->wrapTable($query->from) => [ ] ]; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -182,16 +182,16 @@ discard block |
||
182 | 182 | */ |
183 | 183 | protected function compileComponents(Builder $query) |
184 | 184 | { |
185 | - $sql = []; |
|
185 | + $sql = [ ]; |
|
186 | 186 | |
187 | 187 | foreach ($this->selectComponents as $component) { |
188 | 188 | // To compile the query, we'll spin through each component of the query and |
189 | 189 | // see if that component exists. If it does we'll just call the compiler |
190 | 190 | // function for the component which is responsible for making the SQL. |
191 | 191 | if (!is_null($query->$component)) { |
192 | - $method = 'compile' . ucfirst($component); |
|
192 | + $method = 'compile'.ucfirst($component); |
|
193 | 193 | |
194 | - $sql[$component] = $this->$method($query, $query->$component); |
|
194 | + $sql[ $component ] = $this->$method($query, $query->$component); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | $select = $query->distinct ? 'select distinct ' : 'select '; |
218 | 218 | |
219 | - return $select . $this->columnize($columns); |
|
219 | + return $select.$this->columnize($columns); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | protected function compileFrom(Builder $query, $table) |
230 | 230 | { |
231 | - return 'from ' . $this->wrapTable($table); |
|
231 | + return 'from '.$this->wrapTable($table); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | protected function compileWheres(Builder $query) |
241 | 241 | { |
242 | - $sql = []; |
|
242 | + $sql = [ ]; |
|
243 | 243 | |
244 | 244 | if (is_null($query->wheres)) { |
245 | 245 | return ''; |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | // for actually creating the where clauses SQL. This helps keep the code nice |
250 | 250 | // and maintainable since each clause has a very small method that it uses. |
251 | 251 | foreach ($query->wheres as $where) { |
252 | - $method = "where{$where['type']}"; |
|
252 | + $method = "where{$where[ 'type' ]}"; |
|
253 | 253 | |
254 | - $sql[] = $where['boolean'].' '.$this->$method($query, $where); |
|
254 | + $sql[ ] = $where[ 'boolean' ].' '.$this->$method($query, $where); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | // If we actually have some where clauses, we will strip off the first boolean |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | protected function compileOrders(Builder $query, $orders) |
277 | 277 | { |
278 | - return 'order by '.implode(', ', $orders[0])." ".$orders[1]; |
|
278 | + return 'order by '.implode(', ', $orders[ 0 ])." ".$orders[ 1 ]; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | */ |
300 | 300 | protected function compileAggregate(Builder $query, $aggregate) |
301 | 301 | { |
302 | - $column = $this->columnize($aggregate['columns']); |
|
302 | + $column = $this->columnize($aggregate[ 'columns' ]); |
|
303 | 303 | |
304 | 304 | // If the query has a "distinct" constraint and we're not asking for all columns |
305 | 305 | // we need to prepend "distinct" onto the column name so that the query takes |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | $column = 'distinct '.$column; |
309 | 309 | } |
310 | 310 | |
311 | - return 'select '.$aggregate['function'].'('.$column.') as aggregate'; |
|
311 | + return 'select '.$aggregate[ 'function' ].'('.$column.') as aggregate'; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | protected function whereBasic(Builder $query, $where) |
341 | 341 | { |
342 | 342 | // $value = $this->parameter($where['value']); |
343 | - return $this->wrap($where['column']).' '.$where['operator'].' ?'; //.$value; |
|
343 | + return $this->wrap($where[ 'column' ]).' '.$where[ 'operator' ].' ?'; //.$value; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | */ |
353 | 353 | protected function whereBetween(Builder $query, $where) |
354 | 354 | { |
355 | - $between = $where['not'] ? 'not between' : 'between'; |
|
355 | + $between = $where[ 'not' ] ? 'not between' : 'between'; |
|
356 | 356 | |
357 | - return $this->wrap($where['column']).' '.$between.' ? and ?'; |
|
357 | + return $this->wrap($where[ 'column' ]).' '.$between.' ? and ?'; |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -366,18 +366,18 @@ discard block |
||
366 | 366 | */ |
367 | 367 | protected function whereIn(Builder $query, $where) |
368 | 368 | { |
369 | - $in = $where['not'] ? 'not in' : 'in'; |
|
369 | + $in = $where[ 'not' ] ? 'not in' : 'in'; |
|
370 | 370 | |
371 | 371 | $values = " ("; |
372 | 372 | |
373 | 373 | $count = count($query->getBindings()); |
374 | 374 | for ($i = 1; $i <= $count; $i++) { |
375 | - $append = ($count > $i) ? "," : ""; |
|
376 | - $values .= "?" . $append; |
|
375 | + $append = ($count > $i) ? "," : ""; |
|
376 | + $values .= "?".$append; |
|
377 | 377 | } |
378 | 378 | $values .= ")"; |
379 | 379 | |
380 | - return $this->wrap($where['column']). ' '.$in.$values; |
|
380 | + return $this->wrap($where[ 'column' ]).' '.$in.$values; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -389,9 +389,9 @@ discard block |
||
389 | 389 | */ |
390 | 390 | protected function whereNull(Builder $query, $where) |
391 | 391 | { |
392 | - $null = $where['not'] ? 'is not null' : 'is null'; |
|
392 | + $null = $where[ 'not' ] ? 'is not null' : 'is null'; |
|
393 | 393 | |
394 | - return $this->wrap($where['column']). ' '.$null; |
|
394 | + return $this->wrap($where[ 'column' ]).' '.$null; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | */ |
404 | 404 | protected function whereDate(Builder $builder, $where) |
405 | 405 | { |
406 | - return $this->wrap($where['column']).$where['operator'].$where['value']; |
|
406 | + return $this->wrap($where[ 'column' ]).$where[ 'operator' ].$where[ 'value' ]; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | */ |
416 | 416 | protected function whereYear(Builder $builder, $where) |
417 | 417 | { |
418 | - return "year(".$this->wrap($where['column']).")".$where['operator'].$where['value']; |
|
418 | + return "year(".$this->wrap($where[ 'column' ]).")".$where[ 'operator' ].$where[ 'value' ]; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | */ |
428 | 428 | protected function whereMonth(Builder $builder, $where) |
429 | 429 | { |
430 | - return "month(".$this->wrap($where['column']).")".$where['operator'].$where['value']; |
|
430 | + return "month(".$this->wrap($where[ 'column' ]).")".$where[ 'operator' ].$where[ 'value' ]; |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | */ |
440 | 440 | protected function whereDay(Builder $builder, $where) |
441 | 441 | { |
442 | - return "day(".$this->wrap($where['column']).")".$where['operator'].$where['value']; |
|
442 | + return "day(".$this->wrap($where[ 'column' ]).")".$where[ 'operator' ].$where[ 'value' ]; |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | /** |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | */ |
451 | 451 | protected function concatenate($segments) |
452 | 452 | { |
453 | - return implode(' ', array_filter($segments, function ($value) { |
|
454 | - return (string)$value !== ''; |
|
453 | + return implode(' ', array_filter($segments, function($value) { |
|
454 | + return (string) $value !== ''; |
|
455 | 455 | })); |
456 | 456 | } |
457 | 457 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | */ |
464 | 464 | public function columnize(array $columns) |
465 | 465 | { |
466 | - return implode(', ', array_map([$this, 'wrap'], $columns)); |
|
466 | + return implode(', ', array_map([ $this, 'wrap' ], $columns)); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -474,10 +474,10 @@ discard block |
||
474 | 474 | */ |
475 | 475 | public function parameterize(array $values) |
476 | 476 | { |
477 | - $val = array_map([$this, 'parameter'], $values); |
|
477 | + $val = array_map([ $this, 'parameter' ], $values); |
|
478 | 478 | |
479 | 479 | foreach ($val as $key => $item) { |
480 | - $val[$key] = $this->quoteString($item); |
|
480 | + $val[ $key ] = $this->quoteString($item); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | return implode(', ', $val); |
@@ -485,11 +485,11 @@ discard block |
||
485 | 485 | |
486 | 486 | public function parameterizeForUpdate(array $columns, array $values) |
487 | 487 | { |
488 | - $queryValues = []; |
|
488 | + $queryValues = [ ]; |
|
489 | 489 | |
490 | 490 | $count = count($values); |
491 | 491 | for ($i = 0; $i < $count; $i++) { |
492 | - $queryValues[] = $columns[$i]."=".$this->quoteString(array_values($values)[$i]); |
|
492 | + $queryValues[ ] = $columns[ $i ]."=".$this->quoteString(array_values($values)[ $i ]); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | return implode(", ", $queryValues); |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | public function quoteString($value) |
516 | 516 | { |
517 | 517 | if (is_array($value)) { |
518 | - return implode(', ', array_map([$this, __FUNCTION__], $value)); |
|
518 | + return implode(', ', array_map([ $this, __FUNCTION__ ], $value)); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | return "'$value'"; |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | public function wrapTable($table) |
531 | 531 | { |
532 | 532 | if (!$this->isExpression($table)) { |
533 | - return $this->wrap($this->tablePrefix . $table, true); |
|
533 | + return $this->wrap($this->tablePrefix.$table, true); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | return $this->getValue($table); |
@@ -556,13 +556,13 @@ discard block |
||
556 | 556 | $segments = explode(' ', $value); |
557 | 557 | |
558 | 558 | if ($prefixAlias) { |
559 | - $segments[2] = $this->tablePrefix.$segments[2]; |
|
559 | + $segments[ 2 ] = $this->tablePrefix.$segments[ 2 ]; |
|
560 | 560 | } |
561 | 561 | |
562 | - return $this->wrap($segments[0]).' as '.$this->wrapValue($segments[2]); |
|
562 | + return $this->wrap($segments[ 0 ]).' as '.$this->wrapValue($segments[ 2 ]); |
|
563 | 563 | } |
564 | 564 | |
565 | - $wrapped = []; |
|
565 | + $wrapped = [ ]; |
|
566 | 566 | |
567 | 567 | $segments = explode('.', $value); |
568 | 568 | |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | // segments as if it was a table and the rest as just regular values. |
572 | 572 | foreach ($segments as $key => $segment) { |
573 | 573 | if ($key == 0 && count($segments) > 1) { |
574 | - $wrapped[] = $this->wrapTable($segment); |
|
574 | + $wrapped[ ] = $this->wrapTable($segment); |
|
575 | 575 | } else { |
576 | - $wrapped[] = $this->wrapValue($segment); |
|
576 | + $wrapped[ ] = $this->wrapValue($segment); |
|
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
@@ -595,11 +595,11 @@ discard block |
||
595 | 595 | // as well in order to generate proper syntax. If this is a column of course |
596 | 596 | // no prefix is necessary. The condition will be true when from wrapTable. |
597 | 597 | if ($prefixAlias) { |
598 | - $segments[1] = $this->tablePrefix . $segments[1]; |
|
598 | + $segments[ 1 ] = $this->tablePrefix.$segments[ 1 ]; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | return $this->wrap( |
602 | - $segments[0]) . ' as ' . $this->wrapValue($segments[1] |
|
602 | + $segments[ 0 ]).' as '.$this->wrapValue($segments[ 1 ] |
|
603 | 603 | ); |
604 | 604 | } |
605 | 605 | |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | */ |
612 | 612 | protected function wrapSegments($segments) |
613 | 613 | { |
614 | - return arr($segments)->map(function ($segment, $key) use ($segments) { |
|
614 | + return arr($segments)->map(function($segment, $key) use ($segments) { |
|
615 | 615 | return $key == 0 && count($segments) > 1 |
616 | 616 | ? $this->wrapTable($segment) |
617 | 617 | : $this->wrapValue($segment); |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | protected function wrapValue($value) |
628 | 628 | { |
629 | 629 | if ($value !== '*') { |
630 | - return '`' . str_replace('"', '""', $value) . '`'; |
|
630 | + return '`'.str_replace('"', '""', $value).'`'; |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | return $value; |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | * @var array |
50 | 50 | */ |
51 | 51 | protected $bindings = [ |
52 | - 'select' => [], |
|
53 | - 'join' => [], |
|
54 | - 'where' => [], |
|
55 | - 'having' => [], |
|
56 | - 'order' => [], |
|
57 | - 'union' => [], |
|
52 | + 'select' => [ ], |
|
53 | + 'join' => [ ], |
|
54 | + 'where' => [ ], |
|
55 | + 'having' => [ ], |
|
56 | + 'order' => [ ], |
|
57 | + 'union' => [ ], |
|
58 | 58 | ]; |
59 | 59 | |
60 | 60 | /** |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function addArrayOfWheres($column, string $boolean) |
143 | 143 | { |
144 | - return $this->whereNested(function ($query) use ($column) { |
|
144 | + return $this->whereNested(function($query) use ($column) { |
|
145 | 145 | |
146 | 146 | /** @var Builder $query */ |
147 | 147 | foreach ($column as $key => $value) { |
148 | 148 | if (is_numeric($key) && is_array($value)) { |
149 | - call_user_func_array([$query, 'where'], $value); |
|
149 | + call_user_func_array([ $query, 'where' ], $value); |
|
150 | 150 | } else { |
151 | 151 | $query->where($key, '=', $value); |
152 | 152 | } |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function addBinding($value, $type = 'where') |
207 | 207 | { |
208 | - if (! array_key_exists($type, $this->bindings)) { |
|
208 | + if (!array_key_exists($type, $this->bindings)) { |
|
209 | 209 | throw new InvalidArgumentException("Invalid binding type: {$type}."); |
210 | 210 | } |
211 | 211 | |
212 | 212 | if (is_array($value)) { |
213 | - $this->bindings[$type] = array_values(array_merge($this->bindings[$type], $value)); |
|
213 | + $this->bindings[ $type ] = array_values(array_merge($this->bindings[ $type ], $value)); |
|
214 | 214 | } else { |
215 | - $this->bindings[$type][] = $value; |
|
215 | + $this->bindings[ $type ][ ] = $value; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | return $this; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param array|mixed $columns |
246 | 246 | * @return $this |
247 | 247 | */ |
248 | - public function select($columns = ['*']) |
|
248 | + public function select($columns = [ '*' ]) |
|
249 | 249 | { |
250 | 250 | $this->columns = is_array($columns) ? $columns : func_get_args(); |
251 | 251 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @param array $bindings |
258 | 258 | * @return mixed |
259 | 259 | */ |
260 | - public function selectRaw(string $query, array $bindings = []) |
|
260 | + public function selectRaw(string $query, array $bindings = [ ]) |
|
261 | 261 | { |
262 | 262 | return $this->connection->select($query, $bindings); |
263 | 263 | } |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | return true; |
273 | 273 | } |
274 | 274 | |
275 | - if (! is_array(reset($values))) { |
|
276 | - $values = [$values]; |
|
275 | + if (!is_array(reset($values))) { |
|
276 | + $values = [ $values ]; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | // Here, we will sort the insert keys for every record so that each insert is |
@@ -282,18 +282,18 @@ discard block |
||
282 | 282 | else { |
283 | 283 | foreach ($values as $key => $value) { |
284 | 284 | ksort($value); |
285 | - $values[$key] = $value; |
|
285 | + $values[ $key ] = $value; |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
289 | 289 | // We'll treat every insert like a batch insert so we can easily insert each |
290 | 290 | // of the records into the database consistently. This will make it much |
291 | 291 | // easier on the grammars to just handle one type of record insertion. |
292 | - $bindings = []; |
|
292 | + $bindings = [ ]; |
|
293 | 293 | |
294 | 294 | foreach ($values as $record) { |
295 | 295 | foreach ($record as $value) { |
296 | - $bindings[] = $value; |
|
296 | + $bindings[ ] = $value; |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | { |
349 | 349 | $wrapped = $this->grammar->wrap($column); |
350 | 350 | |
351 | - $columns = array_merge([$column => $this->raw("$wrapped + $amount")]); |
|
351 | + $columns = array_merge([ $column => $this->raw("$wrapped + $amount") ]); |
|
352 | 352 | |
353 | 353 | return $this->update($columns); |
354 | 354 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | { |
365 | 365 | $wrapped = $this->grammar->wrap($column); |
366 | 366 | |
367 | - $columns = array_merge([$column => $this->raw("$wrapped - $amount")]); |
|
367 | + $columns = array_merge([ $column => $this->raw("$wrapped - $amount") ]); |
|
368 | 368 | |
369 | 369 | return $this->update($columns); |
370 | 370 | } |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | // If an ID is passed to the method, we will set the where clause to check |
381 | 381 | // the ID to allow developers to simply and quickly remove a single row |
382 | 382 | // from their database without manually specifying the where clauses. |
383 | - if (! is_null($id)) { |
|
383 | + if (!is_null($id)) { |
|
384 | 384 | $this->where('id', '=', $id); |
385 | 385 | } |
386 | 386 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * @param array $bindings |
407 | 407 | * @return bool |
408 | 408 | */ |
409 | - public function insertRaw(string $query, array $bindings = []) |
|
409 | + public function insertRaw(string $query, array $bindings = [ ]) |
|
410 | 410 | { |
411 | 411 | return $this->connection->insert($query, $bindings); |
412 | 412 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @param array $bindings |
417 | 417 | * @return int |
418 | 418 | */ |
419 | - public function updateRaw(string $query, array $bindings = []) |
|
419 | + public function updateRaw(string $query, array $bindings = [ ]) |
|
420 | 420 | { |
421 | 421 | return $this->connection->update($query, $bindings); |
422 | 422 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @param array $bindings |
427 | 427 | * @return int |
428 | 428 | */ |
429 | - public function deleteRaw(string $query, array $bindings = []) |
|
429 | + public function deleteRaw(string $query, array $bindings = [ ]) |
|
430 | 430 | { |
431 | 431 | return $this->connection->delete($query, $bindings); |
432 | 432 | } |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | // passed to the method, we will assume that the operator is an equals sign |
467 | 467 | // and keep going. Otherwise, we'll require the operator to be passed in. |
468 | 468 | if (func_num_args() == 2) { |
469 | - list($value, $operator) = [$operator, '=']; |
|
469 | + list($value, $operator) = [ $operator, '=' ]; |
|
470 | 470 | } elseif ($this->invalidOperatorAndValue($operator, $value)) { |
471 | 471 | throw new InvalidArgumentException('Illegal operator and value combination.'); |
472 | 472 | } |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | // If the given operator is not found in the list of valid operators we will |
475 | 475 | // assume that the developer is just short-cutting the '=' operators and |
476 | 476 | // we will set the operators to '=' and set the values appropriately. |
477 | - if (! in_array(strtolower($operator), $this->operators, true)) { |
|
478 | - list($value, $operator) = [$operator, '=']; |
|
477 | + if (!in_array(strtolower($operator), $this->operators, true)) { |
|
478 | + list($value, $operator) = [ $operator, '=' ]; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | // If the value is a Closure, it means the developer is performing an entire |
@@ -497,9 +497,9 @@ discard block |
||
497 | 497 | // will be bound to each SQL statements when it is finally executed. |
498 | 498 | $type = 'Basic'; |
499 | 499 | |
500 | - $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean'); |
|
500 | + $this->wheres[ ] = compact('type', 'column', 'operator', 'value', 'boolean'); |
|
501 | 501 | |
502 | - if (! $value instanceof Expression) { |
|
502 | + if (!$value instanceof Expression) { |
|
503 | 503 | $this->addBinding($value, 'where'); |
504 | 504 | } |
505 | 505 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | { |
520 | 520 | $type = 'in'; |
521 | 521 | |
522 | - $this->wheres[] = compact('column', 'type', 'boolean', 'not'); |
|
522 | + $this->wheres[ ] = compact('column', 'type', 'boolean', 'not'); |
|
523 | 523 | |
524 | 524 | $this->addBinding($values, 'where'); |
525 | 525 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | { |
577 | 577 | $type = 'between'; |
578 | 578 | |
579 | - $this->wheres[] = compact('column', 'type', 'boolean', 'not'); |
|
579 | + $this->wheres[ ] = compact('column', 'type', 'boolean', 'not'); |
|
580 | 580 | |
581 | 581 | $this->addBinding($values, 'where'); |
582 | 582 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | if (count($query->wheres)) { |
661 | 661 | $type = 'Nested'; |
662 | 662 | |
663 | - $this->wheres[] = compact('type', 'query', 'boolean'); |
|
663 | + $this->wheres[ ] = compact('type', 'query', 'boolean'); |
|
664 | 664 | |
665 | 665 | $this->addBinding($query->getBindings(), 'where'); |
666 | 666 | } |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | // in the array of where clauses for the "main" parent query instance. |
689 | 689 | call_user_func($callback, $query); |
690 | 690 | |
691 | - $this->wheres[] = compact('type', 'column', 'operator', 'query', 'boolean'); |
|
691 | + $this->wheres[ ] = compact('type', 'column', 'operator', 'query', 'boolean'); |
|
692 | 692 | |
693 | 693 | $this->addBinding($query->getBindings(), 'where'); |
694 | 694 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | { |
708 | 708 | $type = 'Null'; |
709 | 709 | |
710 | - $this->wheres[] = compact('type', 'column', 'boolean', 'not'); |
|
710 | + $this->wheres[ ] = compact('type', 'column', 'boolean', 'not'); |
|
711 | 711 | |
712 | 712 | return $this; |
713 | 713 | } |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | */ |
828 | 828 | protected function addDateBasedWhere($type, $column, $operator, $value, $boolean = 'and') |
829 | 829 | { |
830 | - $this->wheres[] = compact('column', 'type', 'boolean', 'operator', 'value'); |
|
830 | + $this->wheres[ ] = compact('column', 'type', 'boolean', 'operator', 'value'); |
|
831 | 831 | |
832 | 832 | $this->addBinding($value, 'where'); |
833 | 833 | |
@@ -843,11 +843,11 @@ discard block |
||
843 | 843 | */ |
844 | 844 | public function orderBy($column, $direction = 'asc') |
845 | 845 | { |
846 | - if(!($direction == 'asc' or $direction == 'desc')) { |
|
846 | + if (!($direction == 'asc' or $direction == 'desc')) { |
|
847 | 847 | handle(new Exception("Order by direction invalid: '".$direction."'")); |
848 | 848 | } |
849 | 849 | |
850 | - $column = is_array($column) ? $column : [$column]; |
|
850 | + $column = is_array($column) ? $column : [ $column ]; |
|
851 | 851 | |
852 | 852 | $this->orders = [ |
853 | 853 | $column, |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | * @param array $columns |
892 | 892 | * @return ArrayObject|null |
893 | 893 | */ |
894 | - public function get(array $columns = ['*'], $executeSQLWithoutSeprateBindings = false) |
|
894 | + public function get(array $columns = [ '*' ], $executeSQLWithoutSeprateBindings = false) |
|
895 | 895 | { |
896 | 896 | $this->columns = $columns; |
897 | 897 | |
@@ -960,11 +960,11 @@ discard block |
||
960 | 960 | * @param array $columns |
961 | 961 | * @return Model |
962 | 962 | */ |
963 | - public function first(array $columns = ['*']) |
|
963 | + public function first(array $columns = [ '*' ]) |
|
964 | 964 | { |
965 | 965 | $this->limit(1); |
966 | 966 | |
967 | - return $this->get($columns)[0]; |
|
967 | + return $this->get($columns)[ 0 ]; |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | /** |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | */ |
976 | 976 | public function value(string $val) |
977 | 977 | { |
978 | - return $this->first([$val])->$val; |
|
978 | + return $this->first([ $val ])->$val; |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | /** |
@@ -986,8 +986,8 @@ discard block |
||
986 | 986 | */ |
987 | 987 | public function count($columns = '*') |
988 | 988 | { |
989 | - if (! is_array($columns)) { |
|
990 | - $columns = [$columns]; |
|
989 | + if (!is_array($columns)) { |
|
990 | + $columns = [ $columns ]; |
|
991 | 991 | } |
992 | 992 | |
993 | 993 | return (int) $this->aggregate(__FUNCTION__, $columns); |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | */ |
1002 | 1002 | public function min(string $column) |
1003 | 1003 | { |
1004 | - return $this->aggregate(__FUNCTION__, [$column]); |
|
1004 | + return $this->aggregate(__FUNCTION__, [ $column ]); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | /** |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | public function max($column) |
1014 | 1014 | { |
1015 | - return $this->aggregate(__FUNCTION__, [$column]); |
|
1015 | + return $this->aggregate(__FUNCTION__, [ $column ]); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | /** |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | public function sum($column) |
1025 | 1025 | { |
1026 | - $result = $this->aggregate(__FUNCTION__, [$column]); |
|
1026 | + $result = $this->aggregate(__FUNCTION__, [ $column ]); |
|
1027 | 1027 | |
1028 | 1028 | return $result ?: 0; |
1029 | 1029 | } |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | */ |
1037 | 1037 | public function avg($column) |
1038 | 1038 | { |
1039 | - return $this->aggregate(__FUNCTION__, [$column]); |
|
1039 | + return $this->aggregate(__FUNCTION__, [ $column ]); |
|
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | /** |
@@ -1071,10 +1071,10 @@ discard block |
||
1071 | 1071 | |
1072 | 1072 | $results = $this->connection->select($sql); |
1073 | 1073 | |
1074 | - if (isset($results[0])) { |
|
1075 | - $results = (array) $results[0]; |
|
1074 | + if (isset($results[ 0 ])) { |
|
1075 | + $results = (array) $results[ 0 ]; |
|
1076 | 1076 | |
1077 | - return (bool) $results['exists']; |
|
1077 | + return (bool) $results[ 'exists' ]; |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | return false; |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | */ |
1088 | 1088 | public function doesntExist() |
1089 | 1089 | { |
1090 | - return ! $this->exists(); |
|
1090 | + return !$this->exists(); |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | /** |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | * @param array $columns |
1098 | 1098 | * @return float|int |
1099 | 1099 | */ |
1100 | - public function aggregate($function, $columns = ['*']) |
|
1100 | + public function aggregate($function, $columns = [ '*' ]) |
|
1101 | 1101 | { |
1102 | 1102 | $this->aggregate = compact('function', 'columns'); |
1103 | 1103 | |
@@ -1112,10 +1112,10 @@ discard block |
||
1112 | 1112 | |
1113 | 1113 | $this->columns = $previousColumns; |
1114 | 1114 | |
1115 | - if (isset($results[0])) { |
|
1116 | - $result = array_change_key_case((array) $results[0]); |
|
1115 | + if (isset($results[ 0 ])) { |
|
1116 | + $result = array_change_key_case((array) $results[ 0 ]); |
|
1117 | 1117 | |
1118 | - return $result['aggregate']; |
|
1118 | + return $result[ 'aggregate' ]; |
|
1119 | 1119 | } |
1120 | 1120 | } |
1121 | 1121 | |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | private function isOperatorValid($operatorToCheck) |
1131 | 1131 | { |
1132 | 1132 | foreach ($this->operators as $operator) { |
1133 | - if($operatorToCheck === $operator) { |
|
1133 | + if ($operatorToCheck === $operator) { |
|
1134 | 1134 | return true; |
1135 | 1135 | } |
1136 | 1136 | } |
@@ -1156,8 +1156,8 @@ discard block |
||
1156 | 1156 | */ |
1157 | 1157 | protected function cleanBindings(array $bindings) |
1158 | 1158 | { |
1159 | - return array_values(array_filter($bindings, function ($binding) { |
|
1160 | - return ! $binding instanceof Expression; |
|
1159 | + return array_values(array_filter($bindings, function($binding) { |
|
1160 | + return !$binding instanceof Expression; |
|
1161 | 1161 | })); |
1162 | 1162 | } |
1163 | 1163 | |
@@ -1171,13 +1171,13 @@ discard block |
||
1171 | 1171 | protected function prepareRawQuery(string $query, array $bindings): string |
1172 | 1172 | { |
1173 | 1173 | // search for values in query |
1174 | - preg_match_all("/:([^ ]*)/", $query,$values); |
|
1174 | + preg_match_all("/:([^ ]*)/", $query, $values); |
|
1175 | 1175 | |
1176 | 1176 | // replace values with bindings |
1177 | - foreach ($values[1] as $value) { |
|
1177 | + foreach ($values[ 1 ] as $value) { |
|
1178 | 1178 | // check if fitting binding exists |
1179 | - if(array_key_exists($value, $bindings)) { |
|
1180 | - $query = str_replace(":".$value, $bindings[$value], $query); |
|
1179 | + if (array_key_exists($value, $bindings)) { |
|
1180 | + $query = str_replace(":".$value, $bindings[ $value ], $query); |
|
1181 | 1181 | } else { |
1182 | 1182 | handle(new Exception("Could not find fitting value '$value' in bindings for query: '$query'")); |
1183 | 1183 | } |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | AbstractRouteFactory $route_factory = null |
209 | 209 | ) { |
210 | 210 | // Instanciate and fall back to defaults |
211 | - $this->service = $service ?: new ServiceProvider(); |
|
212 | - $this->app = $app ?: new App(); |
|
213 | - $this->routes = $routes ?: new RouteCollection(); |
|
211 | + $this->service = $service ?: new ServiceProvider(); |
|
212 | + $this->app = $app ?: new App(); |
|
213 | + $this->routes = $routes ?: new RouteCollection(); |
|
214 | 214 | $this->route_factory = $route_factory ?: new RouteFactory(); |
215 | 215 | |
216 | 216 | $this->error_callbacks = new SplStack(); |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | $capture = self::DISPATCH_NO_CAPTURE |
405 | 405 | ) { |
406 | 406 | // Set/Initialize our objects to be sent in each callback |
407 | - $this->request = $request ?: Request::createFromGlobals(); |
|
407 | + $this->request = $request ?: Request::createFromGlobals(); |
|
408 | 408 | $this->response = $response ?: new Response(); |
409 | 409 | |
410 | 410 | // Bind our objects to our service |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | // Test for HEAD request (like GET) |
469 | 469 | if (strcasecmp($req_method, 'HEAD') === 0 |
470 | 470 | && (strcasecmp($method, 'HEAD') === 0 |
471 | - || strcasecmp($method, 'GET') === 0 ) |
|
471 | + || strcasecmp($method, 'GET') === 0) |
|
472 | 472 | ) { |
473 | 473 | |
474 | 474 | $method_match = true; |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | $possible_match = (null === $method_match) || $method_match; |
482 | 482 | |
483 | 483 | // ! is used to negate a match |
484 | - if (isset($path[0]) && $path[0] === '!') { |
|
484 | + if (isset($path[ 0 ]) && $path[ 0 ] === '!') { |
|
485 | 485 | $negate = true; |
486 | 486 | $i = 1; |
487 | 487 | } else { |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | |
507 | 507 | continue; |
508 | 508 | |
509 | - } elseif (isset($path[$i]) && $path[$i] === '@') { |
|
509 | + } elseif (isset($path[ $i ]) && $path[ $i ] === '@') { |
|
510 | 510 | // @ is used to specify custom regex |
511 | 511 | |
512 | - $match = preg_match('`' . substr($path, $i + 1) . '`', $uri, $params); |
|
512 | + $match = preg_match('`'.substr($path, $i + 1).'`', $uri, $params); |
|
513 | 513 | |
514 | 514 | } else { |
515 | 515 | // Compiling and matching regular expressions is relatively |
@@ -518,25 +518,25 @@ discard block |
||
518 | 518 | $expression = null; |
519 | 519 | $regex = false; |
520 | 520 | $j = 0; |
521 | - $n = isset($path[$i]) ? $path[$i] : null; |
|
521 | + $n = isset($path[ $i ]) ? $path[ $i ] : null; |
|
522 | 522 | |
523 | 523 | // Find the longest non-regex substring and match it against the URI |
524 | 524 | while (true) { |
525 | - if (!isset($path[$i])) { |
|
525 | + if (!isset($path[ $i ])) { |
|
526 | 526 | break; |
527 | 527 | } elseif (false === $regex) { |
528 | 528 | $c = $n; |
529 | 529 | $regex = $c === '[' || $c === '(' || $c === '.'; |
530 | - if (false === $regex && false !== isset($path[$i+1])) { |
|
531 | - $n = $path[$i + 1]; |
|
530 | + if (false === $regex && false !== isset($path[ $i + 1 ])) { |
|
531 | + $n = $path[ $i + 1 ]; |
|
532 | 532 | $regex = $n === '?' || $n === '+' || $n === '*' || $n === '{'; |
533 | 533 | } |
534 | - if (false === $regex && $c !== '/' && (!isset($uri[$j]) || $c !== $uri[$j])) { |
|
534 | + if (false === $regex && $c !== '/' && (!isset($uri[ $j ]) || $c !== $uri[ $j ])) { |
|
535 | 535 | continue 2; |
536 | 536 | } |
537 | 537 | $j++; |
538 | 538 | } |
539 | - $expression .= $path[$i++]; |
|
539 | + $expression .= $path[ $i++ ]; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | try { |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | } else { |
646 | 646 | // Output capturing behavior |
647 | - switch($capture) { |
|
647 | + switch ($capture) { |
|
648 | 648 | case self::DISPATCH_CAPTURE_AND_RETURN: |
649 | 649 | $buffed_content = null; |
650 | 650 | while (ob_get_level() >= $this->output_buffer_level) { |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | protected function doMiddleware(Route $route) |
707 | 707 | { |
708 | 708 | /** @var MiddlewareInterface $middleware */ |
709 | - foreach($route->getMiddleware() as $middleware) { |
|
709 | + foreach ($route->getMiddleware() as $middleware) { |
|
710 | 710 | $middleware->handle($this->request()); |
711 | 711 | } |
712 | 712 | } |
@@ -722,8 +722,8 @@ discard block |
||
722 | 722 | // First escape all of the non-named param (non [block]s) for regex-chars |
723 | 723 | $route = preg_replace_callback( |
724 | 724 | static::ROUTE_ESCAPE_REGEX, |
725 | - function ($match) { |
|
726 | - return preg_quote($match[0]); |
|
725 | + function($match) { |
|
726 | + return preg_quote($match[ 0 ]); |
|
727 | 727 | }, |
728 | 728 | $route |
729 | 729 | ); |
@@ -734,11 +734,11 @@ discard block |
||
734 | 734 | // Now let's actually compile the path |
735 | 735 | $route = preg_replace_callback( |
736 | 736 | static::ROUTE_COMPILE_REGEX, |
737 | - function ($match) use ($match_types) { |
|
737 | + function($match) use ($match_types) { |
|
738 | 738 | list(, $pre, $type, $param, $optional) = $match; |
739 | 739 | |
740 | - if (isset($match_types[$type])) { |
|
741 | - $type = $match_types[$type]; |
|
740 | + if (isset($match_types[ $type ])) { |
|
741 | + $type = $match_types[ $type ]; |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | // Older versions of PCRE require the 'P' in (?P<named>) |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | |
780 | 780 | // Set an error handler temporarily |
781 | 781 | set_error_handler( |
782 | - function ($errno, $errstr) use (&$error_string) { |
|
782 | + function($errno, $errstr) use (&$error_string) { |
|
783 | 783 | $error_string = $errstr; |
784 | 784 | }, |
785 | 785 | E_NOTICE | E_WARNING |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | |
833 | 833 | // Make sure we are getting a valid route |
834 | 834 | if (null === $route) { |
835 | - throw new OutOfBoundsException('No such route with name: '. $route_name); |
|
835 | + throw new OutOfBoundsException('No such route with name: '.$route_name); |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | $path = $route->getPath(); |
@@ -840,11 +840,11 @@ discard block |
||
840 | 840 | // Use our compilation regex to reverse the path's compilation from its definition |
841 | 841 | $reversed_path = preg_replace_callback( |
842 | 842 | static::ROUTE_COMPILE_REGEX, |
843 | - function ($match) use ($params) { |
|
844 | - list($block, $pre, , $param, $optional) = $match; |
|
843 | + function($match) use ($params) { |
|
844 | + list($block, $pre,, $param, $optional) = $match; |
|
845 | 845 | |
846 | - if (isset($params[$param])) { |
|
847 | - return $pre. $params[$param]; |
|
846 | + if (isset($params[ $param ])) { |
|
847 | + return $pre.$params[ $param ]; |
|
848 | 848 | } elseif ($optional) { |
849 | 849 | return ''; |
850 | 850 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @var array |
87 | 87 | */ |
88 | - protected $middleware = []; |
|
88 | + protected $middleware = [ ]; |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Methods |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | if (!is_string($callback)) { |
133 | 133 | if (!is_callable($callback)) { |
134 | 134 | throw new InvalidArgumentException( |
135 | - 'Expected a callable or string. Got an uncallable or not string'. gettype($callback) |
|
135 | + 'Expected a callable or string. Got an uncallable or not string'.gettype($callback) |
|
136 | 136 | ); |
137 | 137 | } |
138 | 138 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | // Allow null, otherwise expect an array or a string |
188 | 188 | if (null !== $method && !is_array($method) && !is_string($method)) { |
189 | - throw new InvalidArgumentException('Expected an array or string. Got a '. gettype($method)); |
|
189 | + throw new InvalidArgumentException('Expected an array or string. Got a '.gettype($method)); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $this->method = $method; |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function middleware(string $name) |
268 | 268 | { |
269 | - $obj = $this->getFromConfig("middleware")[$name]; |
|
269 | + $obj = $this->getFromConfig("middleware")[ $name ]; |
|
270 | 270 | |
271 | 271 | if (is_null($obj)) { |
272 | - $obj = $this->getFromConfig("groups")[$name]; |
|
272 | + $obj = $this->getFromConfig("groups")[ $name ]; |
|
273 | 273 | } |
274 | 274 | |
275 | - $this->middleware[$name] = $obj; |
|
275 | + $this->middleware[ $name ] = $obj; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | { |
301 | 301 | foreach ($middleware as $name => $class) { |
302 | 302 | if (class_exists($class)) { |
303 | - $this->middleware[$name] = new $class; |
|
303 | + $this->middleware[ $name ] = new $class; |
|
304 | 304 | } else { |
305 | 305 | // if $class is object we dont throw an |
306 | 306 | // exception because middleware was already created. |
307 | - if (! is_object($class)) { |
|
307 | + if (!is_object($class)) { |
|
308 | 308 | throw new MiddlewareNotFoundException("Middleware `%s` not found", $name); |
309 | 309 | } |
310 | 310 | } |
@@ -10,8 +10,8 @@ |
||
10 | 10 | */ |
11 | 11 | use app\framework\Component\Routing\Router; |
12 | 12 | |
13 | -Router::get("/", function() { |
|
14 | - view("welcome", ["version" => version()]); |
|
13 | +Router::get("/", function() { |
|
14 | + view("welcome", [ "version" => version() ]); |
|
15 | 15 | }); |
16 | 16 | |
17 | 17 | Router::get("/home", function() { |
@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | -if(! function_exists("dd")) { |
|
2 | +if (!function_exists("dd")) { |
|
3 | 3 | /** |
4 | 4 | * Little helper called dump and die |
5 | 5 | * @param $val |
6 | 6 | */ |
7 | 7 | function dd($val) { |
8 | - \app\framework\Component\VarDumper\VarDumper::dump($val);die; |
|
8 | + \app\framework\Component\VarDumper\VarDumper::dump($val); die; |
|
9 | 9 | } |
10 | 10 | } |
11 | 11 | |
12 | -if(! function_exists("pathTo")) { |
|
12 | +if (!function_exists("pathTo")) { |
|
13 | 13 | /** |
14 | 14 | * Easy function to get the path to the project + if you want an directory in it. |
15 | 15 | * |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | -if(! function_exists("view")) { |
|
24 | +if (!function_exists("view")) { |
|
25 | 25 | /** |
26 | 26 | * Get the evaluated view contents for the given view. |
27 | 27 | * |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * @param array $data Data to set values in template file |
30 | 30 | * @return \app\framework\Component\View\View|string |
31 | 31 | */ |
32 | - function view($view = null, $data = []) { |
|
33 | - $data['auth'] = new \app\framework\Component\Auth\Auth; |
|
32 | + function view($view = null, $data = [ ]) { |
|
33 | + $data[ 'auth' ] = new \app\framework\Component\Auth\Auth; |
|
34 | 34 | $View = new \app\framework\Component\View\View($view, $data); |
35 | 35 | return $View->render(); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -if(! function_exists("app")) { |
|
39 | +if (!function_exists("app")) { |
|
40 | 40 | /** |
41 | 41 | * Used to easily call Methods from classes without manually set |
42 | 42 | * locally Instances of them. |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | * @param array $param To declare what parameter shall be passed to the method |
46 | 46 | * @return mixed |
47 | 47 | */ |
48 | - function app($classMethod, $param = []) { |
|
49 | - return $GLOBALS["App"]->call($classMethod, $param); |
|
48 | + function app($classMethod, $param = [ ]) { |
|
49 | + return $GLOBALS[ "App" ]->call($classMethod, $param); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -if(! function_exists("url")) { |
|
53 | +if (!function_exists("url")) { |
|
54 | 54 | /** |
55 | 55 | * Basically completes just the the url |
56 | 56 | * e.g. /test to yourexample.site/test |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * @return string |
63 | 63 | */ |
64 | 64 | function url($path) { |
65 | - return $_SERVER['HTTP_HOST'].$path; |
|
65 | + return $_SERVER[ 'HTTP_HOST' ].$path; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -if(! function_exists("getStringBetween")) { |
|
69 | +if (!function_exists("getStringBetween")) { |
|
70 | 70 | /** |
71 | 71 | * This is a handy little function to strip out a string between |
72 | 72 | * two specified pieces of text. This could be used to parse |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return bool|string |
79 | 79 | */ |
80 | 80 | function getStringBetween($string, $start, $end) { |
81 | - $string = ' ' . $string; |
|
81 | + $string = ' '.$string; |
|
82 | 82 | $ini = strpos($string, $start); |
83 | 83 | if ($ini == 0) return ''; |
84 | 84 | $ini += strlen($start); |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -if(! function_exists("handle")) { |
|
91 | - function handle( $e) { |
|
90 | +if (!function_exists("handle")) { |
|
91 | + function handle($e) { |
|
92 | 92 | \app\framework\Component\Exception\Handler::getInstance()->handler($e); |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -if(! function_exists("arr")) { |
|
96 | +if (!function_exists("arr")) { |
|
97 | 97 | /** |
98 | 98 | * Create an ArrayObject from array |
99 | 99 | * @param array $arr |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -if(! function_exists("str")) { |
|
107 | +if (!function_exists("str")) { |
|
108 | 108 | function str($str) { |
109 | 109 | return new \app\framework\Component\StdLib\StdObject\StringObject\StringObject($str); |
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | -if(! function_exists("encrypt")) { |
|
113 | +if (!function_exists("encrypt")) { |
|
114 | 114 | /** |
115 | 115 | * Encrypt the given value. |
116 | 116 | * |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | \app\framework\Component\Config\Config::getInstance()->get("CrypKey") |
125 | 125 | ); |
126 | 126 | |
127 | - return $Encryptor->encrypt($value, $serialize ); |
|
127 | + return $Encryptor->encrypt($value, $serialize); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | -if(! function_exists("decrypt")) { |
|
131 | +if (!function_exists("decrypt")) { |
|
132 | 132 | /** |
133 | 133 | * Decrypt the given value. |
134 | 134 | * |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | \app\framework\Component\Config\Config::getInstance()->get("CrypKey") |
143 | 143 | ); |
144 | 144 | |
145 | - return $Encryptor->decrypt($value, $unserialize ); |
|
145 | + return $Encryptor->decrypt($value, $unserialize); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | -if(! function_exists("version")) { |
|
149 | +if (!function_exists("version")) { |
|
150 | 150 | /** |
151 | 151 | * @return string version as written in config/app.php |
152 | 152 | */ |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | -if(! function_exists("isDebug")) { |
|
158 | +if (!function_exists("isDebug")) { |
|
159 | 159 | function isDebug() { |
160 | 160 | return \app\framework\Component\Config\Config::getInstance()->get("debug", "app"); |
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | -if(! function_exists("class_basename")) { |
|
164 | +if (!function_exists("class_basename")) { |
|
165 | 165 | /** |
166 | 166 | * Get the class "basename" of the given object / class. |
167 | 167 | * |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | -if (! function_exists("get_connection_log")) |
|
178 | +if (!function_exists("get_connection_log")) |
|
179 | 179 | { |
180 | 180 | /** |
181 | 181 | * returns query log from Connection as array |