ImageController::destroy()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Larafolio\Http\Controllers;
4
5
use Larafolio\Models\Image;
6
use Illuminate\Http\Request;
7
8
class ImageController extends Controller
9
{
10
    /**
11
     * Update image name and caption.
12
     *
13
     * @param \Illuminate\Http\Request $request Request object.
14
     * @param Image                    $image   Image to be updated.
15
     *
16
     * @return \Illuminate\Http\Response
17
     */
18
    public function update(Request $request, Image $image)
19
    {
20
        $imageData = $request->only(['name', 'caption', 'alt']);
21
22
        $this->user->updateImageInfo($image, $imageData);
23
24
        if ($request->ajax()) {
25
            return response()->json(true);
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a string|array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
26
        }
27
28
        return back();
29
    }
30
31
    /**
32
     * Remove image from portfolio.
33
     *
34
     * @param Image $image Image to be removed.
35
     *
36
     * @return \Illuminate\Http\Response
37
     */
38
    public function destroy(Request $request, Image $image)
39
    {
40
        $this->user->removeImage($image);
41
42
        if ($request->ajax()) {
43
            return response()->json(true);
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a string|array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
44
        }
45
46
        return back();
47
    }
48
}
49