AssetController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 16
dl 0
loc 30
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getIndex() 0 28 4
1
<?php namespace Distilleries\Expendable\Http\Controllers\Frontend;
2
3
use Distilleries\Expendable\Http\Controllers\Frontend\Base\BaseController;
4
5
class AssetController extends BaseController {
6
7 8
    public function getIndex($path = '')
8
    {
9
10 8
        $directory   = explode('/', $path);
11 8
        $directory   = reset($directory);
12 8
        $white_liste = config('expendable.folder_whitelist');
13 8
        if (in_array($directory, $white_liste))
14
        {
15 6
            $path = storage_path($path);
16 6
            $filesystem = app('files');
17 6
            if ($filesystem->isFile($path))
18
            {
19 4
                $mimetype = mime_content_type($path);
20 4
                if (@is_array(getimagesize($path)))
21
                {
22 2
                    return response()->make($filesystem->get($path), 200, array('content-type' => $mimetype));
23
                } else
24
                {
25 2
                    $name = explode('/', $path);
26 2
                    $name = end($name);
27
28 2
                    return response()->download($path, $name, array('content-type' => $mimetype));
29
                }
30
            }
31
        }
32
33
34 4
        return abort(404);
0 ignored issues
show
Bug introduced by
Are you sure the usage of abort(404) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
35
    }
36
}