Passed
Pull Request — 2.x (#597)
by Antonio Carlos
06:56
created

IconsController::show()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 10
ccs 0
cts 5
cp 0
crap 6
rs 10
1
<?php
2
3
namespace A17\Twill\Http\Controllers\Admin;
4
5
use Illuminate\Filesystem\Filesystem;
6
use Illuminate\Support\Facades\Storage;
7
8
class IconsController extends Controller
9
{
10
    public function __construct(Filesystem $files)
11
    {
12
        $this->files = $files;
0 ignored issues
show
Bug Best Practice introduced by
The property files does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
13
    }
14
15
    public function show($file)
16
    {
17
        $file = __DIR__ . "/../../../../frontend/icons/{$file}";
18
19
        if (!$this->files->exists($file)) {
20
            abort(404);
21
        }
22
23
        return response()->stream(function () use ($file) {
24
            echo $this->files->get($file);
25
        });
26
    }
27
}
28