for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace UniSharp\Uploadable\Plugins;
use Intervention\Image\Facades\Image;
use Illuminate\Support\Facades\Storage;
class WatermarkPlugin
{
public function handle($path)
$image = Image::make($path);
$image->insert($this->getWatermark($image), 'bottom-right');
$image->save();
}
protected function getWatermark($image)
$storagePath = Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix();
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
$a = "a"; $ab = "ab"; $abc = "abc";
will produce issues in the first and second line, while this second example
will produce no issues.
$watermarkPath = $storagePath . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'watermark.png';
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.
$watermark = Image::make($watermarkPath);
$watermark->resize($image->getWidth() / 2.5, null, function ($constraint) {
TRUE
FALSE
NULL
null
$constraint->aspectRatio();
$constraint->upsize();
});
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.
return $watermark;
This check marks files that end in a newline character, i.e. an empy line.