Passed
Push — dev6 ( 735134...809e49 )
by Ron
15:35
created

UploadImageController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 5
c 1
b 0
f 0
dl 0
loc 14
ccs 0
cts 5
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 1
1
<?php
2
3
namespace App\Http\Controllers\Home;
4
5
use App\Http\Controllers\Controller;
6
use App\Http\Requests\Home\UploadImageRequest;
7
use Illuminate\Http\File;
8
use Illuminate\Http\Request;
9
use Illuminate\Support\Facades\Log;
10
use Illuminate\Support\Facades\Storage;
11
12
class UploadImageController extends Controller
13
{
14
    /**
15
     *  Upload an image that will be used in a text editor field
16
     */
17
    public function __invoke(UploadImageRequest $request)
18
    {
19
        //  Storage Path
20
        $path = 'images/uploaded';
21
        $location = Storage::disk('public')->putFile($path, new File($request->file));
22
23
        Log::channel('user')->info('New image uploaded by '.$request->user()->username, $request->toArray());
24
25
        return Storage::url($location);
1 ignored issue
show
Bug introduced by
It seems like $location can also be of type false; however, parameter $path of Illuminate\Support\Facades\Storage::url() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
        return Storage::url(/** @scrutinizer ignore-type */ $location);
Loading history...
26
    }
27
}
28