1 | <?php |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | |||
0 ignored issues
–
show
|
|||
3 | namespace UniSharp\Uploadable\Plugins; |
||
4 | |||
5 | use Illuminate\Support\Facades\File; |
||
6 | use Intervention\Image\Facades\Image; |
||
7 | use Illuminate\Support\Facades\Config; |
||
8 | |||
9 | class ImagePlugin |
||
0 ignored issues
–
show
|
|||
10 | { |
||
0 ignored issues
–
show
|
|||
11 | 2 | public function handle($path) |
|
0 ignored issues
–
show
|
|||
12 | { |
||
0 ignored issues
–
show
|
|||
13 | 2 | $image = Image::make($path); |
|
14 | |||
15 | 2 | if (Config::get('uploadable.use_image_orientate', false)) { |
|
0 ignored issues
–
show
|
|||
16 | 2 | $image->orientate(); |
|
17 | } |
||
18 | |||
19 | 2 | $image->save($path, 100); |
|
20 | |||
21 | 2 | foreach (Config::get('uploadable.thumbs', []) as $name => $size) { |
|
0 ignored issues
–
show
|
|||
22 | 2 | $img = clone $image; |
|
23 | |||
24 | 2 | [$width, $height] = explode('x', $size); |
|
0 ignored issues
–
show
|
|||
25 | |||
26 | 2 | $img->resize($width, $height, function ($constraint) { |
|
0 ignored issues
–
show
|
|||
27 | $constraint->aspectRatio(); |
||
28 | $constraint->upsize(); |
||
29 | 2 | })->save($this->getThumbFilePath($img, $name), 100); |
|
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.
![]() |
|||
30 | } |
||
31 | 2 | } |
|
0 ignored issues
–
show
|
|||
32 | |||
33 | 2 | public function getThumbsDirectory($baseDir, $name) |
|
0 ignored issues
–
show
|
|||
34 | { |
||
0 ignored issues
–
show
|
|||
35 | 2 | $directory = $baseDir . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR; |
|
0 ignored issues
–
show
|
|||
36 | |||
37 | 2 | if (!File::exists($directory)) { |
|
0 ignored issues
–
show
|
|||
38 | 2 | File::makeDirectory($directory); |
|
39 | } |
||
40 | |||
41 | 2 | return $directory; |
|
42 | } |
||
0 ignored issues
–
show
|
|||
43 | |||
44 | 2 | public function getThumbFilePath($image, $name) |
|
0 ignored issues
–
show
|
|||
45 | { |
||
0 ignored issues
–
show
|
|||
46 | 2 | return $this->getThumbsDirectory($image->dirname, $name) . |
|
0 ignored issues
–
show
|
|||
47 | 2 | $image->filename . |
|
0 ignored issues
–
show
|
|||
48 | 2 | '.' . |
|
0 ignored issues
–
show
|
|||
49 | 2 | $image->extension; |
|
50 | } |
||
0 ignored issues
–
show
|
|||
51 | } |
||
0 ignored issues
–
show
|
|||
52 |