UniSharp /
laravel-uploadable
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | |||
|
0 ignored issues
–
show
|
|||
| 3 | namespace UniSharp\Uploadable; |
||
| 4 | |||
| 5 | use Illuminate\Support\Facades\URL; |
||
| 6 | |||
| 7 | class Image extends File |
||
|
0 ignored issues
–
show
|
|||
| 8 | { |
||
|
0 ignored issues
–
show
|
|||
| 9 | protected $table = 'files'; |
||
|
0 ignored issues
–
show
|
|||
| 10 | |||
| 11 | protected $appends = ['thumb']; |
||
|
0 ignored issues
–
show
|
|||
| 12 | |||
| 13 | public function getThumbAttribute(): array |
||
|
0 ignored issues
–
show
|
|||
| 14 | { |
||
|
0 ignored issues
–
show
|
|||
| 15 | 2 | return collect(['s', 'm', 'l'])->flip()->map(function ($_, $size) { |
|
|
0 ignored issues
–
show
|
|||
| 16 | 2 | return URL::to(preg_replace('/^(images\/)/', "\$1{$size}/", $this->attributes['path'])); |
|
|
0 ignored issues
–
show
As per coding-style, please use concatenation or
sprintf for the variable $size instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
|
|||
| 17 | 2 | })->toArray(); |
|
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 18 | } |
||
|
0 ignored issues
–
show
|
|||
| 19 | } |
||
|
0 ignored issues
–
show
|
|||
| 20 |