@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @var array Connection |
24 | 24 | */ |
25 | - private $connections = []; |
|
25 | + private $connections = [ ]; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @var string $connectionToUse |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function __construct() |
42 | 42 | { |
43 | 43 | // use default connection |
44 | - if($this->connectionToUse == null) { |
|
44 | + if ($this->connectionToUse == null) { |
|
45 | 45 | $this->connection(); |
46 | 46 | $this->useConnection(); |
47 | 47 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | $connection = ConnectionFactory::getInstance()->get($name); |
59 | 59 | |
60 | - $this->connections[$connection->getName()] = $connection; |
|
60 | + $this->connections[ $connection->getName() ] = $connection; |
|
61 | 61 | |
62 | 62 | return $this; |
63 | 63 | } |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getConnection(string $name = null) |
72 | 72 | { |
73 | - if($name == null) { |
|
73 | + if ($name == null) { |
|
74 | 74 | reset($this->connections); |
75 | - $Connection = $this->connections[key($this->connections)]; |
|
75 | + $Connection = $this->connections[ key($this->connections) ]; |
|
76 | 76 | } else { |
77 | - $Connection = $this->connections[$name]; |
|
77 | + $Connection = $this->connections[ $name ]; |
|
78 | 78 | } |
79 | 79 | |
80 | - if(isset($Connection)) { |
|
80 | + if (isset($Connection)) { |
|
81 | 81 | return $Connection; |
82 | 82 | } else { |
83 | 83 | return false; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function useConnection(string $name = null): Manager |
93 | 93 | { |
94 | 94 | $this->connectionToUse = $this->getConnection($name)->getName(); |
95 | - $this->QueryBuilder = new Builder($this->connections[$this->connectionToUse]); |
|
95 | + $this->QueryBuilder = new Builder($this->connections[ $this->connectionToUse ]); |
|
96 | 96 | |
97 | 97 | return $this; |
98 | 98 | } |
@@ -101,29 +101,29 @@ discard block |
||
101 | 101 | * @param array $columns |
102 | 102 | * @return Builder |
103 | 103 | */ |
104 | - public function select($columns = ['*']) |
|
104 | + public function select($columns = [ '*' ]) |
|
105 | 105 | { |
106 | 106 | $this->QueryBuilder->select($columns); |
107 | 107 | |
108 | 108 | return $this->QueryBuilder; |
109 | 109 | } |
110 | 110 | |
111 | - public function selectRaw(string $query, array $bindings = []) |
|
111 | + public function selectRaw(string $query, array $bindings = [ ]) |
|
112 | 112 | { |
113 | 113 | return $this->QueryBuilder->selectRaw($query, $bindings); |
114 | 114 | } |
115 | 115 | |
116 | - public function insertRaw(string $query, array $bindings = []) |
|
116 | + public function insertRaw(string $query, array $bindings = [ ]) |
|
117 | 117 | { |
118 | 118 | return $this->QueryBuilder->insertRaw($query, $bindings); |
119 | 119 | } |
120 | 120 | |
121 | - public function updateRaw(string $query, array $bindings = []) |
|
121 | + public function updateRaw(string $query, array $bindings = [ ]) |
|
122 | 122 | { |
123 | 123 | return $this->QueryBuilder->updateRaw($query, $bindings); |
124 | 124 | } |
125 | 125 | |
126 | - public function deleteRaw(string $query, array $bindings = []) |
|
126 | + public function deleteRaw(string $query, array $bindings = [ ]) |
|
127 | 127 | { |
128 | 128 | return $this->QueryBuilder->deleteRaw($query, $bindings); |
129 | 129 | } |
@@ -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); |
@@ -124,18 +124,18 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function compileUpdate(Builder $query, array $values): string |
126 | 126 | { |
127 | - $table = $this->wrapTable($query->from); |
|
127 | + $table = $this->wrapTable($query->from); |
|
128 | 128 | |
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 | /** |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | */ |
339 | 339 | protected function whereBasic(Builder $query, $where) |
340 | 340 | { |
341 | - $value = $this->parameter($where['value']); |
|
341 | + $value = $this->parameter($where[ 'value' ]); |
|
342 | 342 | |
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,10 +485,10 @@ discard block |
||
485 | 485 | |
486 | 486 | public function parameterizeForUpdate(array $columns, array $values) |
487 | 487 | { |
488 | - $queryValues = []; |
|
488 | + $queryValues = [ ]; |
|
489 | 489 | |
490 | 490 | for ($i = 0; $i < count($values); $i++) { |
491 | - $queryValues[] = $columns[$i]."=".$this->quoteString(array_values($values)[$i]); |
|
491 | + $queryValues[ ] = $columns[ $i ]."=".$this->quoteString(array_values($values)[ $i ]); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | return implode(", ", $queryValues); |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | public function quoteString($value) |
515 | 515 | { |
516 | 516 | if (is_array($value)) { |
517 | - return implode(', ', array_map([$this, __FUNCTION__], $value)); |
|
517 | + return implode(', ', array_map([ $this, __FUNCTION__ ], $value)); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | return "'$value'"; |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | public function wrapTable($table) |
530 | 530 | { |
531 | 531 | if (!$this->isExpression($table)) { |
532 | - return $this->wrap($this->tablePrefix . $table, true); |
|
532 | + return $this->wrap($this->tablePrefix.$table, true); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | return $this->getValue($table); |
@@ -555,13 +555,13 @@ discard block |
||
555 | 555 | $segments = explode(' ', $value); |
556 | 556 | |
557 | 557 | if ($prefixAlias) { |
558 | - $segments[2] = $this->tablePrefix.$segments[2]; |
|
558 | + $segments[ 2 ] = $this->tablePrefix.$segments[ 2 ]; |
|
559 | 559 | } |
560 | 560 | |
561 | - return $this->wrap($segments[0]).' as '.$this->wrapValue($segments[2]); |
|
561 | + return $this->wrap($segments[ 0 ]).' as '.$this->wrapValue($segments[ 2 ]); |
|
562 | 562 | } |
563 | 563 | |
564 | - $wrapped = []; |
|
564 | + $wrapped = [ ]; |
|
565 | 565 | |
566 | 566 | $segments = explode('.', $value); |
567 | 567 | |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | // segments as if it was a table and the rest as just regular values. |
571 | 571 | foreach ($segments as $key => $segment) { |
572 | 572 | if ($key == 0 && count($segments) > 1) { |
573 | - $wrapped[] = $this->wrapTable($segment); |
|
573 | + $wrapped[ ] = $this->wrapTable($segment); |
|
574 | 574 | } else { |
575 | - $wrapped[] = $this->wrapValue($segment); |
|
575 | + $wrapped[ ] = $this->wrapValue($segment); |
|
576 | 576 | } |
577 | 577 | } |
578 | 578 | |
@@ -594,11 +594,11 @@ discard block |
||
594 | 594 | // as well in order to generate proper syntax. If this is a column of course |
595 | 595 | // no prefix is necessary. The condition will be true when from wrapTable. |
596 | 596 | if ($prefixAlias) { |
597 | - $segments[1] = $this->tablePrefix . $segments[1]; |
|
597 | + $segments[ 1 ] = $this->tablePrefix.$segments[ 1 ]; |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | return $this->wrap( |
601 | - $segments[0]) . ' as ' . $this->wrapValue($segments[1] |
|
601 | + $segments[ 0 ]).' as '.$this->wrapValue($segments[ 1 ] |
|
602 | 602 | ); |
603 | 603 | } |
604 | 604 | |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | */ |
611 | 611 | protected function wrapSegments($segments) |
612 | 612 | { |
613 | - return arr($segments)->map(function ($segment, $key) use ($segments) { |
|
613 | + return arr($segments)->map(function($segment, $key) use ($segments) { |
|
614 | 614 | return $key == 0 && count($segments) > 1 |
615 | 615 | ? $this->wrapTable($segment) |
616 | 616 | : $this->wrapValue($segment); |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | protected function wrapValue($value) |
627 | 627 | { |
628 | 628 | if ($value !== '*') { |
629 | - return '`' . str_replace('"', '""', $value) . '`'; |
|
629 | + return '`'.str_replace('"', '""', $value).'`'; |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | return $value; |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | * @var array |
49 | 49 | */ |
50 | 50 | protected $bindings = [ |
51 | - 'select' => [], |
|
52 | - 'join' => [], |
|
53 | - 'where' => [], |
|
54 | - 'having' => [], |
|
55 | - 'order' => [], |
|
56 | - 'union' => [], |
|
51 | + 'select' => [ ], |
|
52 | + 'join' => [ ], |
|
53 | + 'where' => [ ], |
|
54 | + 'having' => [ ], |
|
55 | + 'order' => [ ], |
|
56 | + 'union' => [ ], |
|
57 | 57 | ]; |
58 | 58 | |
59 | 59 | /** |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function addArrayOfWheres($column, string $boolean) |
142 | 142 | { |
143 | - return $this->whereNested(function ($query) use ($column) { |
|
143 | + return $this->whereNested(function($query) use ($column) { |
|
144 | 144 | |
145 | 145 | /** @var Builder $query */ |
146 | 146 | foreach ($column as $key => $value) { |
147 | 147 | if (is_numeric($key) && is_array($value)) { |
148 | - call_user_func_array([$query, 'where'], $value); |
|
148 | + call_user_func_array([ $query, 'where' ], $value); |
|
149 | 149 | } else { |
150 | 150 | $query->where($key, '=', $value); |
151 | 151 | } |
@@ -204,14 +204,14 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function addBinding($value, $type = 'where') |
206 | 206 | { |
207 | - if (! array_key_exists($type, $this->bindings)) { |
|
207 | + if (!array_key_exists($type, $this->bindings)) { |
|
208 | 208 | throw new InvalidArgumentException("Invalid binding type: {$type}."); |
209 | 209 | } |
210 | 210 | |
211 | 211 | if (is_array($value)) { |
212 | - $this->bindings[$type] = array_values(array_merge($this->bindings[$type], $value)); |
|
212 | + $this->bindings[ $type ] = array_values(array_merge($this->bindings[ $type ], $value)); |
|
213 | 213 | } else { |
214 | - $this->bindings[$type][] = $value; |
|
214 | + $this->bindings[ $type ][ ] = $value; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | return $this; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param array|mixed $columns |
245 | 245 | * @return $this |
246 | 246 | */ |
247 | - public function select($columns = ['*']) |
|
247 | + public function select($columns = [ '*' ]) |
|
248 | 248 | { |
249 | 249 | $this->columns = is_array($columns) ? $columns : func_get_args(); |
250 | 250 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param array $bindings |
257 | 257 | * @return mixed |
258 | 258 | */ |
259 | - public function selectRaw(string $query, array $bindings = []) |
|
259 | + public function selectRaw(string $query, array $bindings = [ ]) |
|
260 | 260 | { |
261 | 261 | return $this->connection->select($query, $bindings); |
262 | 262 | } |
@@ -271,8 +271,8 @@ discard block |
||
271 | 271 | return true; |
272 | 272 | } |
273 | 273 | |
274 | - if (! is_array(reset($values))) { |
|
275 | - $values = [$values]; |
|
274 | + if (!is_array(reset($values))) { |
|
275 | + $values = [ $values ]; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | // Here, we will sort the insert keys for every record so that each insert is |
@@ -281,18 +281,18 @@ discard block |
||
281 | 281 | else { |
282 | 282 | foreach ($values as $key => $value) { |
283 | 283 | ksort($value); |
284 | - $values[$key] = $value; |
|
284 | + $values[ $key ] = $value; |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
288 | 288 | // We'll treat every insert like a batch insert so we can easily insert each |
289 | 289 | // of the records into the database consistently. This will make it much |
290 | 290 | // easier on the grammars to just handle one type of record insertion. |
291 | - $bindings = []; |
|
291 | + $bindings = [ ]; |
|
292 | 292 | |
293 | 293 | foreach ($values as $record) { |
294 | 294 | foreach ($record as $value) { |
295 | - $bindings[] = $value; |
|
295 | + $bindings[ ] = $value; |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | { |
348 | 348 | $wrapped = $this->grammar->wrap($column); |
349 | 349 | |
350 | - $columns = array_merge([$column => $this->raw("$wrapped + $amount")]); |
|
350 | + $columns = array_merge([ $column => $this->raw("$wrapped + $amount") ]); |
|
351 | 351 | |
352 | 352 | return $this->update($columns); |
353 | 353 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | { |
364 | 364 | $wrapped = $this->grammar->wrap($column); |
365 | 365 | |
366 | - $columns = array_merge([$column => $this->raw("$wrapped - $amount")]); |
|
366 | + $columns = array_merge([ $column => $this->raw("$wrapped - $amount") ]); |
|
367 | 367 | |
368 | 368 | return $this->update($columns); |
369 | 369 | } |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | // If an ID is passed to the method, we will set the where clause to check |
380 | 380 | // the ID to allow developers to simply and quickly remove a single row |
381 | 381 | // from their database without manually specifying the where clauses. |
382 | - if (! is_null($id)) { |
|
382 | + if (!is_null($id)) { |
|
383 | 383 | $this->where('id', '=', $id); |
384 | 384 | } |
385 | 385 | |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @param array $bindings |
406 | 406 | * @return bool |
407 | 407 | */ |
408 | - public function insertRaw(string $query, array $bindings = []) |
|
408 | + public function insertRaw(string $query, array $bindings = [ ]) |
|
409 | 409 | { |
410 | 410 | return $this->connection->insert($query, $bindings); |
411 | 411 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @param array $bindings |
416 | 416 | * @return int |
417 | 417 | */ |
418 | - public function updateRaw(string $query, array $bindings = []) |
|
418 | + public function updateRaw(string $query, array $bindings = [ ]) |
|
419 | 419 | { |
420 | 420 | return $this->connection->update($query, $bindings); |
421 | 421 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @param array $bindings |
426 | 426 | * @return int |
427 | 427 | */ |
428 | - public function deleteRaw(string $query, array $bindings = []) |
|
428 | + public function deleteRaw(string $query, array $bindings = [ ]) |
|
429 | 429 | { |
430 | 430 | return $this->connection->delete($query, $bindings); |
431 | 431 | } |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | // passed to the method, we will assume that the operator is an equals sign |
466 | 466 | // and keep going. Otherwise, we'll require the operator to be passed in. |
467 | 467 | if (func_num_args() == 2) { |
468 | - list($value, $operator) = [$operator, '=']; |
|
468 | + list($value, $operator) = [ $operator, '=' ]; |
|
469 | 469 | } elseif ($this->invalidOperatorAndValue($operator, $value)) { |
470 | 470 | throw new InvalidArgumentException('Illegal operator and value combination.'); |
471 | 471 | } |
@@ -473,8 +473,8 @@ discard block |
||
473 | 473 | // If the given operator is not found in the list of valid operators we will |
474 | 474 | // assume that the developer is just short-cutting the '=' operators and |
475 | 475 | // we will set the operators to '=' and set the values appropriately. |
476 | - if (! in_array(strtolower($operator), $this->operators, true)) { |
|
477 | - list($value, $operator) = [$operator, '=']; |
|
476 | + if (!in_array(strtolower($operator), $this->operators, true)) { |
|
477 | + list($value, $operator) = [ $operator, '=' ]; |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | // If the value is a Closure, it means the developer is performing an entire |
@@ -496,9 +496,9 @@ discard block |
||
496 | 496 | // will be bound to each SQL statements when it is finally executed. |
497 | 497 | $type = 'Basic'; |
498 | 498 | |
499 | - $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean'); |
|
499 | + $this->wheres[ ] = compact('type', 'column', 'operator', 'value', 'boolean'); |
|
500 | 500 | |
501 | - if (! $value instanceof Expression) { |
|
501 | + if (!$value instanceof Expression) { |
|
502 | 502 | $this->addBinding($value, 'where'); |
503 | 503 | } |
504 | 504 | |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | { |
519 | 519 | $type = 'in'; |
520 | 520 | |
521 | - $this->wheres[] = compact('column', 'type', 'boolean', 'not'); |
|
521 | + $this->wheres[ ] = compact('column', 'type', 'boolean', 'not'); |
|
522 | 522 | |
523 | 523 | $this->addBinding($values, 'where'); |
524 | 524 | |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | { |
576 | 576 | $type = 'between'; |
577 | 577 | |
578 | - $this->wheres[] = compact('column', 'type', 'boolean', 'not'); |
|
578 | + $this->wheres[ ] = compact('column', 'type', 'boolean', 'not'); |
|
579 | 579 | |
580 | 580 | $this->addBinding($values, 'where'); |
581 | 581 | |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | if (count($query->wheres)) { |
660 | 660 | $type = 'Nested'; |
661 | 661 | |
662 | - $this->wheres[] = compact('type', 'query', 'boolean'); |
|
662 | + $this->wheres[ ] = compact('type', 'query', 'boolean'); |
|
663 | 663 | |
664 | 664 | $this->addBinding($query->getBindings(), 'where'); |
665 | 665 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | // in the array of where clauses for the "main" parent query instance. |
688 | 688 | call_user_func($callback, $query); |
689 | 689 | |
690 | - $this->wheres[] = compact('type', 'column', 'operator', 'query', 'boolean'); |
|
690 | + $this->wheres[ ] = compact('type', 'column', 'operator', 'query', 'boolean'); |
|
691 | 691 | |
692 | 692 | $this->addBinding($query->getBindings(), 'where'); |
693 | 693 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | { |
707 | 707 | $type = 'Null'; |
708 | 708 | |
709 | - $this->wheres[] = compact('type', 'column', 'boolean', 'not'); |
|
709 | + $this->wheres[ ] = compact('type', 'column', 'boolean', 'not'); |
|
710 | 710 | |
711 | 711 | return $this; |
712 | 712 | } |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | */ |
827 | 827 | protected function addDateBasedWhere($type, $column, $operator, $value, $boolean = 'and') |
828 | 828 | { |
829 | - $this->wheres[] = compact('column', 'type', 'boolean', 'operator', 'value'); |
|
829 | + $this->wheres[ ] = compact('column', 'type', 'boolean', 'operator', 'value'); |
|
830 | 830 | |
831 | 831 | $this->addBinding($value, 'where'); |
832 | 832 | |
@@ -842,11 +842,11 @@ discard block |
||
842 | 842 | */ |
843 | 843 | public function orderBy($column, $direction = 'asc') |
844 | 844 | { |
845 | - if(!($direction == 'asc' or $direction == 'desc')) { |
|
845 | + if (!($direction == 'asc' or $direction == 'desc')) { |
|
846 | 846 | handle(new Exception("Order by direction invalid: '".$direction."'")); |
847 | 847 | } |
848 | 848 | |
849 | - $column = is_array($column) ? $column : [$column]; |
|
849 | + $column = is_array($column) ? $column : [ $column ]; |
|
850 | 850 | |
851 | 851 | $this->orders = [ |
852 | 852 | $column, |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | * @param array $columns |
891 | 891 | * @return array|null |
892 | 892 | */ |
893 | - public function get(array $columns = ['*']) |
|
893 | + public function get(array $columns = [ '*' ]) |
|
894 | 894 | { |
895 | 895 | $this->columns = $columns; |
896 | 896 | |
@@ -955,11 +955,11 @@ discard block |
||
955 | 955 | * @param array $columns |
956 | 956 | * @return Model |
957 | 957 | */ |
958 | - public function first(array $columns = ['*']) |
|
958 | + public function first(array $columns = [ '*' ]) |
|
959 | 959 | { |
960 | 960 | $this->limit(1); |
961 | 961 | |
962 | - return $this->get($columns)[0]; |
|
962 | + return $this->get($columns)[ 0 ]; |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | /** |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | */ |
971 | 971 | public function value(string $val) |
972 | 972 | { |
973 | - return $this->first([$val])->$val; |
|
973 | + return $this->first([ $val ])->$val; |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | /** |
@@ -981,8 +981,8 @@ discard block |
||
981 | 981 | */ |
982 | 982 | public function count($columns = '*') |
983 | 983 | { |
984 | - if (! is_array($columns)) { |
|
985 | - $columns = [$columns]; |
|
984 | + if (!is_array($columns)) { |
|
985 | + $columns = [ $columns ]; |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | return (int) $this->aggregate(__FUNCTION__, $columns); |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | */ |
997 | 997 | public function min(string $column) |
998 | 998 | { |
999 | - return $this->aggregate(__FUNCTION__, [$column]); |
|
999 | + return $this->aggregate(__FUNCTION__, [ $column ]); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | /** |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | */ |
1008 | 1008 | public function max($column) |
1009 | 1009 | { |
1010 | - return $this->aggregate(__FUNCTION__, [$column]); |
|
1010 | + return $this->aggregate(__FUNCTION__, [ $column ]); |
|
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | /** |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | */ |
1019 | 1019 | public function sum($column) |
1020 | 1020 | { |
1021 | - $result = $this->aggregate(__FUNCTION__, [$column]); |
|
1021 | + $result = $this->aggregate(__FUNCTION__, [ $column ]); |
|
1022 | 1022 | |
1023 | 1023 | return $result ?: 0; |
1024 | 1024 | } |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | */ |
1032 | 1032 | public function avg($column) |
1033 | 1033 | { |
1034 | - return $this->aggregate(__FUNCTION__, [$column]); |
|
1034 | + return $this->aggregate(__FUNCTION__, [ $column ]); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | /** |
@@ -1066,10 +1066,10 @@ discard block |
||
1066 | 1066 | |
1067 | 1067 | $results = $this->connection->select($sql); |
1068 | 1068 | |
1069 | - if (isset($results[0])) { |
|
1070 | - $results = (array) $results[0]; |
|
1069 | + if (isset($results[ 0 ])) { |
|
1070 | + $results = (array) $results[ 0 ]; |
|
1071 | 1071 | |
1072 | - return (bool) $results['exists']; |
|
1072 | + return (bool) $results[ 'exists' ]; |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | return false; |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | */ |
1083 | 1083 | public function doesntExist() |
1084 | 1084 | { |
1085 | - return ! $this->exists(); |
|
1085 | + return !$this->exists(); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | /** |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | * @param array $columns |
1093 | 1093 | * @return float|int |
1094 | 1094 | */ |
1095 | - public function aggregate($function, $columns = ['*']) |
|
1095 | + public function aggregate($function, $columns = [ '*' ]) |
|
1096 | 1096 | { |
1097 | 1097 | $this->aggregate = compact('function', 'columns'); |
1098 | 1098 | |
@@ -1107,10 +1107,10 @@ discard block |
||
1107 | 1107 | |
1108 | 1108 | $this->columns = $previousColumns; |
1109 | 1109 | |
1110 | - if (isset($results[0])) { |
|
1111 | - $result = array_change_key_case((array) $results[0]); |
|
1110 | + if (isset($results[ 0 ])) { |
|
1111 | + $result = array_change_key_case((array) $results[ 0 ]); |
|
1112 | 1112 | |
1113 | - return $result['aggregate']; |
|
1113 | + return $result[ 'aggregate' ]; |
|
1114 | 1114 | } |
1115 | 1115 | } |
1116 | 1116 | |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | private function isOperatorValid($operatorToCheck) |
1126 | 1126 | { |
1127 | 1127 | foreach ($this->operators as $operator) { |
1128 | - if($operatorToCheck === $operator) { |
|
1128 | + if ($operatorToCheck === $operator) { |
|
1129 | 1129 | return true; |
1130 | 1130 | } |
1131 | 1131 | } |
@@ -1151,8 +1151,8 @@ discard block |
||
1151 | 1151 | */ |
1152 | 1152 | protected function cleanBindings(array $bindings) |
1153 | 1153 | { |
1154 | - return array_values(array_filter($bindings, function ($binding) { |
|
1155 | - return ! $binding instanceof Expression; |
|
1154 | + return array_values(array_filter($bindings, function($binding) { |
|
1155 | + return !$binding instanceof Expression; |
|
1156 | 1156 | })); |
1157 | 1157 | } |
1158 | 1158 | |
@@ -1166,13 +1166,13 @@ discard block |
||
1166 | 1166 | protected function prepareRawQuery(string $query, array $bindings): string |
1167 | 1167 | { |
1168 | 1168 | // search for values in query |
1169 | - preg_match_all("/:([^ ]*)/", $query,$values); |
|
1169 | + preg_match_all("/:([^ ]*)/", $query, $values); |
|
1170 | 1170 | |
1171 | 1171 | // replace values with bindings |
1172 | - foreach ($values[1] as $value) { |
|
1172 | + foreach ($values[ 1 ] as $value) { |
|
1173 | 1173 | // check if fitting binding exists |
1174 | - if(array_key_exists($value, $bindings)) { |
|
1175 | - $query = str_replace(":".$value, $bindings[$value], $query); |
|
1174 | + if (array_key_exists($value, $bindings)) { |
|
1175 | + $query = str_replace(":".$value, $bindings[ $value ], $query); |
|
1176 | 1176 | } else { |
1177 | 1177 | handle(new Exception("Could not find fitting value '$value' in bindings for query: '$query'")); |
1178 | 1178 | } |
@@ -6,36 +6,36 @@ |
||
6 | 6 | * @Author Marco Bier <[email protected]> |
7 | 7 | */ |
8 | 8 | |
9 | - namespace app\framework\Component\Storage; |
|
9 | + namespace app\framework\Component\Storage; |
|
10 | 10 | |
11 | - use app\framework\Component\Storage\Directory\Directory; |
|
12 | - use app\framework\Component\Storage\File\File; |
|
11 | + use app\framework\Component\Storage\Directory\Directory; |
|
12 | + use app\framework\Component\Storage\File\File; |
|
13 | 13 | |
14 | - /** |
|
15 | - * A library of Storage functions |
|
16 | - * |
|
17 | - * @package app\framework\Component\Storage |
|
18 | - */ |
|
19 | - trait StorageTrait |
|
20 | - { |
|
21 | - /** |
|
22 | - * Get storage |
|
23 | - * |
|
24 | - * @param $storageName |
|
25 | - * @return Storage |
|
26 | - */ |
|
27 | - protected static function storage($storageName) |
|
28 | - { |
|
29 | - return new Storage($storageName); |
|
30 | - } |
|
14 | + /** |
|
15 | + * A library of Storage functions |
|
16 | + * |
|
17 | + * @package app\framework\Component\Storage |
|
18 | + */ |
|
19 | + trait StorageTrait |
|
20 | + { |
|
21 | + /** |
|
22 | + * Get storage |
|
23 | + * |
|
24 | + * @param $storageName |
|
25 | + * @return Storage |
|
26 | + */ |
|
27 | + protected static function storage($storageName) |
|
28 | + { |
|
29 | + return new Storage($storageName); |
|
30 | + } |
|
31 | 31 | |
32 | - protected function file($key, $storageName) |
|
33 | - { |
|
34 | - return new File($key, self::storage($storageName)); |
|
35 | - } |
|
32 | + protected function file($key, $storageName) |
|
33 | + { |
|
34 | + return new File($key, self::storage($storageName)); |
|
35 | + } |
|
36 | 36 | |
37 | - protected function directory($key, $storageName, $recursive = false, $filter = null) |
|
38 | - { |
|
39 | - return new Directory($key, self::storage($storageName), $recursive, $filter); |
|
40 | - } |
|
41 | - } |
|
37 | + protected function directory($key, $storageName, $recursive = false, $filter = null) |
|
38 | + { |
|
39 | + return new Directory($key, self::storage($storageName), $recursive, $filter); |
|
40 | + } |
|
41 | + } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | class Directory implements DirectoryInterface, IteratorAggregate |
21 | 21 | { |
22 | - use StdLibTrait,EventManagerTrait; |
|
22 | + use StdLibTrait, EventManagerTrait; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * @var string |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function __construct($key, Storage $storage, $recursive = false, $filter = null) |
62 | 62 | { |
63 | - if (! $storage->supportsDirectories()) { |
|
63 | + if (!$storage->supportsDirectories()) { |
|
64 | 64 | $driver = get_class($storage->getDriver()); |
65 | - throw new StorageException(StorageException::DRIVER_CAN_NOT_WORK_WITH_DIRECTORIES, [$driver]); |
|
65 | + throw new StorageException(StorageException::DRIVER_CAN_NOT_WORK_WITH_DIRECTORIES, [ $driver ]); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $this->key = $key; |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | $this->storage = $storage; |
71 | 71 | |
72 | 72 | if (!$this->storage->keyExists($key)) { |
73 | - throw new StorageException(StorageException::DIRECTORY_DOES_NOT_EXIST, [$key]); |
|
73 | + throw new StorageException(StorageException::DIRECTORY_DOES_NOT_EXIST, [ $key ]); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | if (!$this->storage->isDirectory($key)) { |
77 | - throw new StorageException(StorageException::DIRECTORY_OBJECT_CAN_NOT_READ_FILE_PATHS, [$key]); |
|
77 | + throw new StorageException(StorageException::DIRECTORY_OBJECT_CAN_NOT_READ_FILE_PATHS, [ $key ]); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $this->parseFilter($filter); |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | |
254 | 254 | if ($filter->startsWith('*')) { |
255 | 255 | $filter->replace('.', '\.'); |
256 | - $this->regex = '/(\S+)' . $filter . '/'; |
|
256 | + $this->regex = '/(\S+)'.$filter.'/'; |
|
257 | 257 | } elseif ($filter->endsWith('*')) { |
258 | 258 | $filter->replace('.', '\.'); |
259 | - $this->regex = '/' . $filter . '(\S+)/'; |
|
259 | + $this->regex = '/'.$filter.'(\S+)/'; |
|
260 | 260 | } else { |
261 | 261 | $this->regex = $filter; |
262 | 262 | } |
@@ -274,18 +274,18 @@ discard block |
||
274 | 274 | if ($this->regex) { |
275 | 275 | foreach ($keys as $k => $v) { |
276 | 276 | if (!preg_match($this->regex, $v)) { |
277 | - unset($keys[$k]); |
|
277 | + unset($keys[ $k ]); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
282 | 282 | // Instantiate files/directories |
283 | - $this->items = []; |
|
283 | + $this->items = [ ]; |
|
284 | 284 | foreach ($keys as $key) { |
285 | 285 | if ($this->storage->isDirectory($key)) { |
286 | - $this->items[$key] = new static($key, $this->storage); |
|
286 | + $this->items[ $key ] = new static($key, $this->storage); |
|
287 | 287 | } else { |
288 | - $this->items[$key] = new File($key, $this->storage); |
|
288 | + $this->items[ $key ] = new File($key, $this->storage); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | } |
@@ -194,7 +194,7 @@ |
||
194 | 194 | |
195 | 195 | throw new StorageException( |
196 | 196 | StorageException::DRIVER_CAN_NOT_ACCESS_SIZE, |
197 | - [get_class($this->getDriver())] |
|
197 | + [ get_class($this->getDriver()) ] |
|
198 | 198 | ); |
199 | 199 | } |
200 | 200 |
@@ -36,8 +36,8 @@ |
||
36 | 36 | $this->key = $key; |
37 | 37 | |
38 | 38 | //make sure a file path is given |
39 | - if (! $this->storage->keyExists($this->key)) { |
|
40 | - throw new StorageException(StorageException::FILE_NOT_FOUND, [$key]); |
|
39 | + if (!$this->storage->keyExists($this->key)) { |
|
40 | + throw new StorageException(StorageException::FILE_NOT_FOUND, [ $key ]); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | umask($umask); |
50 | 50 | |
51 | 51 | if (!$created) { |
52 | - handle(new StorageException(StorageException::DIRECTORY_COULD_NOT_BE_CREATED, [$directory])); |
|
52 | + handle(new StorageException(StorageException::DIRECTORY_COULD_NOT_BE_CREATED, [ $directory ])); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function ensureDirectoryExists($directory, $create) |
64 | 64 | { |
65 | - if (! is_dir($directory)) { |
|
66 | - if (! $create) { |
|
67 | - throw new StorageException(StorageException::DIRECTORY_DOES_NOT_EXIST, [$directory]); |
|
65 | + if (!is_dir($directory)) { |
|
66 | + if (!$create) { |
|
67 | + throw new StorageException(StorageException::DIRECTORY_DOES_NOT_EXIST, [ $directory ]); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $this->createDirectory($directory); |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | } |
119 | 119 | break; |
120 | 120 | default: |
121 | - $tokens[] = $part; |
|
121 | + $tokens[ ] = $part; |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | - return $prefix . implode('/', $tokens); |
|
125 | + return $prefix.implode('/', $tokens); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | { |
137 | 137 | preg_match('|^(?P<prefix>([a-zA-Z]:)?/)|', $path, $matches); |
138 | 138 | |
139 | - if (empty($matches['prefix'])) { |
|
139 | + if (empty($matches[ 'prefix' ])) { |
|
140 | 140 | return ''; |
141 | 141 | } |
142 | 142 | |
143 | - return strtolower($matches['prefix']); |
|
143 | + return strtolower($matches[ 'prefix' ]); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -157,6 +157,6 @@ discard block |
||
157 | 157 | { |
158 | 158 | $this->ensureDirectoryExists($directory, $create); |
159 | 159 | |
160 | - return $this->normalizeDirectoryPath($directory . '/' . $key); |
|
160 | + return $this->normalizeDirectoryPath($directory.'/'.$key); |
|
161 | 161 | } |
162 | 162 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @package app\framework\Component\Storage\Driver\Local |
29 | 29 | */ |
30 | -class LocalStorageDriver implements SizeAwareInterface,DriverInterface,AbsolutePathInterface,TouchableInterface,DirectoryAwareInterface |
|
30 | +class LocalStorageDriver implements SizeAwareInterface, DriverInterface, AbsolutePathInterface, TouchableInterface, DirectoryAwareInterface |
|
31 | 31 | { |
32 | 32 | /** |
33 | 33 | * @var string |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function __construct($config) |
64 | 64 | { |
65 | - if(is_array($config)){ |
|
65 | + if (is_array($config)) { |
|
66 | 66 | $config = new ArrayObject($config); |
67 | 67 | } |
68 | 68 | |
69 | - if(!$config instanceof ArrayObject){ |
|
69 | + if (!$config instanceof ArrayObject) { |
|
70 | 70 | handle(new StorageException('Storage driver config must be an array or ArrayObject!')); |
71 | 71 | } |
72 | 72 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | { |
122 | 122 | $this->recentKey = $key; |
123 | 123 | |
124 | - if($this->keyExists($key)){ |
|
124 | + if ($this->keyExists($key)) { |
|
125 | 125 | return filesize($this->buildPath($key)); |
126 | 126 | } |
127 | 127 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | $this->recentKey = $key; |
142 | 142 | |
143 | - if($this->keyExists($key)){ |
|
143 | + if ($this->keyExists($key)) { |
|
144 | 144 | return file_get_contents($this->buildPath($key)); |
145 | 145 | } |
146 | 146 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | { |
163 | 163 | $this->recentKey = $key; |
164 | 164 | |
165 | - if($this->keyExists($key)) { |
|
165 | + if ($this->keyExists($key)) { |
|
166 | 166 | return file_put_contents($this->buildPath($key), $contents); |
167 | 167 | } |
168 | 168 | |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | if ($key != '') { |
186 | 186 | $key = ltrim($key, DIRECTORY_SEPARATOR); |
187 | 187 | $key = rtrim($key, DIRECTORY_SEPARATOR); |
188 | - $path = $this->directory . DIRECTORY_SEPARATOR . $key; |
|
188 | + $path = $this->directory.DIRECTORY_SEPARATOR.$key; |
|
189 | 189 | } else { |
190 | 190 | $path = $this->directory; |
191 | 191 | } |
192 | 192 | |
193 | 193 | if (!is_dir($path)) { |
194 | - return []; |
|
194 | + return [ ]; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | if ($recursive) { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | $files = iterator_to_array($iterator); |
211 | 211 | } else { |
212 | - $files = []; |
|
212 | + $files = [ ]; |
|
213 | 213 | $iterator = new DirectoryIterator($path); |
214 | 214 | |
215 | 215 | foreach ($iterator as $fileInfo) { |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | continue; |
220 | 220 | } |
221 | 221 | |
222 | - $files[] = $fileInfo->getPathname(); |
|
222 | + $files[ ] = $fileInfo->getPathname(); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | - $keys = []; |
|
226 | + $keys = [ ]; |
|
227 | 227 | |
228 | 228 | foreach ($files as $file) { |
229 | - $keys[] = $this->helper->getKey($file, $this->directory); |
|
229 | + $keys[ ] = $this->helper->getKey($file, $this->directory); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | sort($keys); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | { |
247 | 247 | $this->recentKey = $key; |
248 | 248 | |
249 | - if($this->keyExists($key)){ |
|
249 | + if ($this->keyExists($key)) { |
|
250 | 250 | return filectime($this->buildPath($key)); |
251 | 251 | } |
252 | 252 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | { |
318 | 318 | $key = str_replace('\\', '/', $key); |
319 | 319 | |
320 | - return $this->publicUrl . '/' . ltrim($key, "/"); |
|
320 | + return $this->publicUrl.'/'.ltrim($key, "/"); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |