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

UploadImageController::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 4
c 2
b 0
f 0
dl 0
loc 8
rs 10
ccs 0
cts 4
cp 0
cc 1
nc 1
nop 1
crap 2
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