Image   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 6
dl 0
loc 11
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getThumbAttribute() 0 5 1
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 "Image.php" doesn't match the expected filename "image.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace UniSharp\Uploadable;
4
5
use Illuminate\Support\Facades\URL;
6
7
class Image extends File
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
8
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class Image
Loading history...
9
    protected $table = 'files';
0 ignored issues
show
Coding Style introduced by
Protected member variable "table" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
10
11
    protected $appends = ['thumb'];
0 ignored issues
show
Coding Style introduced by
Protected member variable "appends" must contain a leading underscore
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
12
13
    public function getThumbAttribute(): array
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
14
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
15 2
        return collect(['s', 'm', 'l'])->flip()->map(function ($_, $size) {
0 ignored issues
show
Coding Style introduced by
Short array syntax is not allowed
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Unused Code introduced by
The method parameter $_ is never used
Loading history...
Coding Style introduced by
Variable "_" is not in valid camel caps format
Loading history...
16 2
            return URL::to(preg_replace('/^(images\/)/', "\$1{$size}/", $this->attributes['path']));
0 ignored issues
show
Coding Style Best Practice introduced by
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
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...
18
    }
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 getThumbAttribute()
Loading history...
19
}
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...
20