Passed
Push — dev6 ( 72e99e...1f4a51 )
by Ron
18:35
created

UploadImageController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 1
1
<?php
2
3
namespace App\Http\Controllers\Home;
4
5
use App\Events\Home\ImageUploadedEvent;
6
use App\Http\Controllers\Controller;
7
use App\Http\Requests\Home\UploadImageRequest;
8
use Illuminate\Http\File;
9
use Illuminate\Http\Request;
10
use Illuminate\Support\Facades\Log;
11
use Illuminate\Support\Facades\Storage;
12
13
class UploadImageController extends Controller
14
{
15
    /**
16
     * Handle the incoming request
17
     */
18
    public function __invoke(UploadImageRequest $request)
19
    {
20
        //  Storage Path
21
        $path = 'images/uploaded';
22
        $location = Storage::disk('public')->putFile($path, new File($request->file));
23
24
        event(new ImageUploadedEvent($location));
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