GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — analysis-d0YOlw ( 094a36 )
by butschster
08:36
created

Images   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 29
dl 0
loc 107
rs 10
c 1
b 0
f 0
wmc 12

7 Methods

Rating   Name   Duplication   Size   Complexity  
A storeAsComaSeparatedValue() 0 8 1
A setDraggable() 0 5 1
A getValueFromModel() 0 14 5
A toArray() 0 7 1
A storeAsJson() 0 7 1
A getDraggable() 0 3 1
A save() 0 14 2
1
<?php
2
3
namespace SleepingOwl\Admin\Form\Element;
4
5
use Illuminate\Http\Request;
6
7
class Images extends Image
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $view = 'form.element.images';
13
14
    protected $draggable = true;
15
16
    /**
17
     * @return bool
18
     */
19
    public function getDraggable()
20
    {
21
        return (bool) $this->draggable;
22
    }
23
24
    /**
25
     * @param bool $draggable
26
     *
27
     * @return $this
28
     */
29
    public function setDraggable($draggable)
30
    {
31
        $this->draggable = $draggable;
32
33
        return $this;
34
    }
35
36
    /**
37
     * Store array of images as json string.
38
     * @return $this
39
     */
40
    public function storeAsJson()
41
    {
42
        $this->mutateValue(function ($value) {
43
            return json_encode($value);
44
        });
45
46
        return $this;
47
    }
48
49
    /**
50
     * Store array of images as coma separator.
51
     * @deprecated
52
     * @return $this
53
     */
54
    public function storeAsComaSeparatedValue()
55
    {
56
        /* deprecated this logic */
57
        // $this->mutateValue(function ($value) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
58
        //     return implode(',', $value);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
59
        // });
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
60
61
        return $this;
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getValueFromModel()
68
    {
69
        $images = $value = parent::getValueFromModel();
70
71
        if (is_null($value)) {
0 ignored issues
show
introduced by
The condition is_null($value) is always false.
Loading history...
72
            $images = [];
73
        } elseif (is_string($value)
74
            && (($images = json_decode($value)) === false
75
                || is_null($images))
76
        ) {
77
            $images = preg_split('/,/', $value, -1, PREG_SPLIT_NO_EMPTY);
78
        }
79
80
        return $images;
81
    }
82
83
    /**
84
     * @param \Illuminate\Http\Request $request
85
     *
86
     * @return void
87
     */
88
    public function save(Request $request)
89
    {
90
        $name = $this->getName();
91
        $value = $request->input($name, '');
92
93
        if (! empty($value)) {
94
            $value = explode(',', $value);
95
        } else {
96
            $value = [];
97
        }
98
99
        $request->merge([$name => $value]);
100
101
        parent::save($request);
102
    }
103
104
    /**
105
     * @return array
106
     */
107
    public function toArray()
108
    {
109
        return array_merge(parent::toArray(), [
110
            'draggable' => $this->getDraggable(),
111
        ]);
112
113
        return $return;
0 ignored issues
show
Unused Code introduced by
return $return is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
114
    }
115
}
116