ImagePlugin::getThumbsDirectory()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
0 ignored issues
show
Coding Style introduced by
This file is missing a doc comment.
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "ImagePlugin.php" doesn't match the expected filename "imageplugin.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
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
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
10
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class ImagePlugin
Loading history...
11 2
    public function handle($path)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
12
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
13 2
        $image = Image::make($path);
14
15 2
        if (Config::get('uploadable.use_image_orientate', false)) {
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of false please use FALSE.
Loading history...
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
Coding Style introduced by
Short array syntax is not allowed
Loading history...
22 2
            $img = clone $image;
23
24 2
            [$width, $height] = explode('x', $size);
0 ignored issues
show
Coding Style introduced by
Arrays with multiple values should not be declared on a single line.
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
25
26 2
            $img->resize($width, $height, function ($constraint) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
27
                $constraint->aspectRatio();
28
                $constraint->upsize();
29 2
            })->save($this->getThumbFilePath($img, $name), 100);
0 ignored issues
show
Coding Style introduced by
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...
30
        }
31 2
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end handle()
Loading history...
32
33 2
    public function getThumbsDirectory($baseDir, $name)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
34
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
35 2
        $directory = $baseDir . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR;
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
36
37 2
        if (!File::exists($directory)) {
0 ignored issues
show
Coding Style introduced by
There must be a single space after a NOT operator; 0 found
Loading history...
38 2
            File::makeDirectory($directory);
39
        }
40
41 2
        return $directory;
42
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getThumbsDirectory()
Loading history...
43
44 2
    public function getThumbFilePath($image, $name)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
45
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
46 2
        return $this->getThumbsDirectory($image->dirname, $name) .
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
47 2
            $image->filename .
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
48 2
            '.' .
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
49 2
            $image->extension;
50
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getThumbFilePath()
Loading history...
51
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
52