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.
Passed
Push — bs4 ( 4509fe...21921a )
by Andrey
04:47 queued 10s
created

SectionModelConfiguration::fireEdit()   B

Complexity

Conditions 9
Paths 33

Size

Total Lines 35
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 9
eloc 19
c 2
b 0
f 0
nc 33
nop 2
dl 0
loc 35
rs 8.0555
1
<?php
2
3
namespace SleepingOwl\Admin\Model;
4
5
use Illuminate\Database\Eloquent\Model;
6
use SleepingOwl\Admin\Contracts\Initializable;
7
use SleepingOwl\Admin\Contracts\Form\FormInterface;
8
use SleepingOwl\Admin\Display\DisplayDatatablesAsync;
9
use SleepingOwl\Admin\Contracts\Display\DisplayInterface;
10
11
class SectionModelConfiguration extends ModelConfigurationManager
12
{
13
    protected $breadcrumbs = null;
14
15
    public function __construct(\Illuminate\Contracts\Foundation\Application $app, $class)
16
    {
17
        parent::__construct($app, $class);
18
19
        $this->breadcrumbs = collect();
20
    }
21
22
    /**
23
     * @return \Illuminate\Support\Collection|null
24
     */
25
    public function getBreadCrumbs()
26
    {
27
        return $this->breadcrumbs->toArray();
28
    }
29
30
    /**
31
     * @param $breadcrumb
32
     * @return mixed|void
33
     */
34
    public function addBreadCrumb($breadcrumb)
35
    {
36
        $this->breadcrumbs->push($breadcrumb);
37
    }
38
39
    /**
40
     * @return bool
41
     */
42
    public function isCreatable()
43
    {
44
        return method_exists($this, 'onCreate') && parent::isCreatable($this->getModel());
0 ignored issues
show
Unused Code introduced by
The call to SleepingOwl\Admin\Model\...nManager::isCreatable() has too many arguments starting with $this->getModel(). ( Ignorable by Annotation )

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

44
        return method_exists($this, 'onCreate') && parent::/** @scrutinizer ignore-call */ isCreatable($this->getModel());

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
45
    }
46
47
    /**
48
     * @param \Illuminate\Database\Eloquent\Model $model
49
     *
50
     * @return bool
51
     */
52
    public function isEditable(Model $model)
53
    {
54
        return method_exists($this, 'onEdit') && parent::isEditable($model);
55
    }
56
57
    /**
58
     * @param \Illuminate\Database\Eloquent\Model $model
59
     *
60
     * @return bool
61
     */
62
    public function isDeletable(Model $model)
63
    {
64
        return method_exists($this, 'onDelete') && parent::isDeletable($model);
65
    }
66
67
    /**
68
     * @param mixed $payload
69
     * @return mixed|DisplayInterface|void
70
     */
71
    public function fireDisplay($payload = [])
72
    {
73
        if (! method_exists($this, 'onDisplay')) {
74
            return;
75
        }
76
77
        $display = $this->app->call([$this, 'onDisplay'], ['payload' => $payload]);
78
79
        if ($display instanceof DisplayDatatablesAsync) {
80
            $display->setPayload($payload);
81
        }
82
83
        if ($display instanceof DisplayInterface) {
84
            $display->setModelClass($this->getClass());
85
            $display->initialize();
86
        }
87
88
        return $display;
89
    }
90
91
    /**
92
     * @param mixed $payload
93
     * @return mixed|void
94
     */
95
    public function fireCreate($payload = [])
96
    {
97
        if (! method_exists($this, 'onCreate')) {
98
            return;
99
        }
100
101
        $form = $this->app->call([$this, 'onCreate'], ['payload' => $payload]);
102
103
        if ($form instanceof DisplayInterface) {
104
            $form->setModelClass($this->getClass());
105
        }
106
107
        if ($form instanceof Initializable) {
108
            $form->initialize();
109
        }
110
111
        if ($form instanceof FormInterface) {
112
            $form->setAction($this->getStoreUrl());
113
        }
114
115
        return $form;
116
    }
117
118
    /**
119
     * @param int $id
120
     * @param mixed $payload
121
     *
122
     * @return mixed|void
123
     */
124
    public function fireEdit($id, $payload = [])
125
    {
126
        if (! method_exists($this, 'onEdit')) {
127
            return;
128
        }
129
130
        $model = $this;
131
        if (method_exists($model, 'getModelValue')) {
132
            $item = $model->getModelValue();
133
            if (! $item) {
134
                $item = $model->getRepository()->find($id);
135
                if (method_exists($model, 'setModelValue') && $item) {
136
                    $model->setModelValue($item);
137
                }
138
            }
139
        }
140
141
        $payload = array_merge(['id' => $id], ['payload' => $payload]);
142
143
        $form = $this->app->call([$this, 'onEdit'], $payload);
144
145
        if ($form instanceof DisplayInterface) {
146
            $form->setModelClass($this->getClass());
147
        }
148
149
        if ($form instanceof Initializable) {
150
            $form->initialize();
151
        }
152
153
        if ($form instanceof FormInterface) {
154
            $form->setAction($this->getUpdateUrl($id));
155
            $form->setId($id);
156
        }
157
158
        return $form;
159
    }
160
161
    /**
162
     * @param $id
163
     *
164
     * @return mixed
165
     */
166
    public function fireDelete($id)
167
    {
168
        if (method_exists($this, 'onDelete')) {
169
            return $this->app->call([$this, 'onDelete'], ['id' => $id]);
170
        }
171
    }
172
173
    /**
174
     * @param $id
175
     *
176
     * @return mixed
177
     */
178
    public function fireDestroy($id)
179
    {
180
        if (method_exists($this, 'onDestroy')) {
181
            return $this->app->call([$this, 'onDestroy'], ['id' => $id]);
182
        }
183
    }
184
185
    /**
186
     * @param $id
187
     *
188
     * @return bool|mixed
189
     */
190
    public function fireRestore($id)
191
    {
192
        if (method_exists($this, 'onRestore')) {
193
            return $this->app->call([$this, 'onRestore'], ['id' => $id]);
194
        }
195
    }
196
}
197