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

IconsController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 17
ccs 0
cts 11
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A show() 0 10 2
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