for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace UniSharp\Uploadable;
use Illuminate\Support\Facades\URL;
class Image extends File
{
protected $table = 'files';
protected $appends = ['thumb'];
public function getThumbAttribute(): array
return collect(['s', 'm', 'l'])->flip()->map(function ($_, $size) {
return URL::to(preg_replace('/^(images\/)/', "\$1{$size}/", $this->attributes['path']));
sprintf
$size
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);
})->toArray();
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.
}
This check marks files that end in a newline character, i.e. an empy line.