Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Plugin::option()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Mark
5
 * Date: 05/03/2016
6
 * Time: 14:42.
7
 */
8
9
namespace App\Model;
10
11
use App\Plugins\PluginHandler;
12
use Illuminate\Database\Eloquent\Model as EloquentModel;
13
14
/**
15
 * Class Plugins.
16
 *
17
 * @property string $name
18
 *
19
 * @property bool $required
20
 * @property bool $enabled
21
 *
22
 * @property PluginHandler $handler
23
 *
24
 * @property Plugin $options
25
 */
26
class Plugin extends EloquentModel
27
{
28
    /**
29
     * The table associated with the model.
30
     *
31
     * @var string
32
     */
33
    protected $table = 'plugins';
34
35
    /**
36
     * The attributes that are mass assignable.
37
     *
38
     * @var array
39
     */
40
    protected $fillable = [];
41
42
    /**
43
     * The table date columns, casted to Carbon.
44
     *
45
     * @var array
46
     */
47
    protected $dates = ['created_at', 'updated_at'];
48
49
    /**
50
     * The attributes that should be cast to native types.
51
     *
52
     * @var array
53
     */
54
    protected $casts = ['enabled' => 'boolean', 'required' => 'boolean'];
55
56
    /**
57
     * Return the plugins namespace.
58
     *
59
     * @return string
60
     */
61
    protected function dirNamespace()
62
    {
63
        return sprintf("App\Plugins\%s", ucfirst($this->name));
64
    }
65
66
    /**
67
     * @return PluginHandler
68
     */
69
    protected function getHandlerAttribute()
70
    {
71
        return app(sprintf("%s\%sController", $this->dirNamespace(), ucfirst($this->name)));
0 ignored issues
show
Bug Best Practice introduced by
The expression return app(sprintf('%s\%... ucfirst($this->name))) also could return the type Illuminate\Foundation\Application which is incompatible with the documented return type App\Plugins\PluginHandler.
Loading history...
72
    }
73
74
    /**
75
     * ==========================================================.
76
     *
77
     *   GET THE ATTRIBUTES OF THE MODEL
78
     *
79
     * ==========================================================
80
     */
81
    public function icon()
82
    {
83
        return $this->handler->icon();
84
    }
85
86
    public function name()
87
    {
88
        return $this->name;
89
    }
90
91
    public function version()
92
    {
93
        return $this->handler->version();
94
    }
95
96
    public function isEnabled()
97
    {
98
        return $this->getAttribute('enabled') == true;
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $this->getAttribute('enabled') of type integer to the boolean true. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
99
    }
100
101
    public function isDisabled()
102
    {
103
        return $this->getAttribute('enabled') == false;
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $this->getAttribute('enabled') of type integer to the boolean false. If you are specifically checking for 0, consider using something more explicit like === 0 instead.
Loading history...
104
    }
105
106
    public function isFrontEnd()
107
    {
108
        return $this->getAttribute('is_frontend');
109
    }
110
111
    public function isBackEnd()
112
    {
113
        return $this->getAttribute('is_backend');
114
    }
115
116
    public function getCreatedAt()
117
    {
118
        return $this->getAttribute('created_at');
119
    }
120
121
    public function getUpdatedAt()
122
    {
123
        return $this->getAttribute('updated_at');
124
    }
125
126
    public function setEnabled($boolean)
127
    {
128
        if ($boolean == true) {
129
            return $this->enable();
130
        }
131
132
        return $this->disable();
133
    }
134
135
    /**
136
     * Enable the product.
137
     *
138
     * @return $this
139
     */
140
    public function enable()
141
    {
142
        $this->setAttribute('enabled', true);
143
144
        return $this;
145
    }
146
147
    /**
148
     * Disable the product.
149
     *
150
     * @return $this
151
     */
152
    public function disable()
153
    {
154
        $this->setAttribute('enabled', false);
155
156
        return $this;
157
    }
158
159
    public function setInstalled(bool $boolean)
160
    {
161
        $this->setAttribute('installed', $boolean ? 1 : 0);
162
163
        return $this;
164
    }
165
166
    /**
167
     * @return mixed
168
     */
169
    public function isInstalled()
170
    {
171
        return $this->getAttribute('installed') ? true : false;
172
    }
173
174
    public function setName($string)
175
    {
176
        $this->setAttribute('name', $string);
177
178
        return $this;
179
    }
180
181
    public function setVersion($integer)
182
    {
183
        $this->setAttribute('version', $integer);
184
185
        return $this;
186
    }
187
188
    public function setIcon($string)
189
    {
190
        $this->setAttribute('icon', $string);
191
192
        return $this;
193
    }
194
195
    public function adminUrl()
196
    {
197
        if ($this->isBackEnd()) {
198
            return route("admin.{$this->name}.index");
199
        }
200
201
        throw new \Exception('This is not a backend enabled plugin and should not be used here.');
202
    }
203
204
    public function userUrl()
205
    {
206
        if ($this->isFrontEnd()) {
207
            return url($this->name());
208
        }
209
210
        throw new \Exception('This is not a frontend enabled plugin and should not be used here.');
211
    }
212
213
    public function isHidden()
214
    {
215
        return $this->getAttribute('hidden') ? true : false;
216
    }
217
218
    public function setHide(bool $boolean)
219
    {
220
        $this->setAttribute('hidden', $boolean ? 1 : 0);
221
222
        return $this;
223
    }
224
225
    public function setRequired($boolean)
226
    {
227
        $this->setAttribute('required', $boolean);
228
229
        return $this;
230
    }
231
232
    public function setFrontEnd($boolean)
233
    {
234
        $this->setAttribute('is_frontend', $boolean);
235
236
        return $this;
237
    }
238
239
    public function setBackEnd($boolean)
240
    {
241
        $this->setAttribute('is_backend', $boolean);
242
243
        return $this;
244
    }
245
246
    /**
247
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
248
     */
249
    public function options()
250
    {
251
        return $this->hasMany(PluginOption::class, 'plugin_id', 'id');
0 ignored issues
show
Bug introduced by
The type App\Model\PluginOption was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
252
    }
253
254
    public function option($key)
255
    {
256
        return $this->options->where('key', $key)->first()->value();
257
    }
258
259
    public function feeds()
260
    {
261
        return $this->hasMany(PluginFeed::class, 'plugin_id', 'id');
0 ignored issues
show
Bug introduced by
The type App\Model\PluginFeed was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
262
    }
263
264
    public function install()
265
    {
266
        $controller = app(printf("App\Plugins\%s", $this->name));
267
268
        $controller->install();
0 ignored issues
show
Bug introduced by
The method install() does not exist on Illuminate\Foundation\Application. ( Ignorable by Annotation )

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

268
        $controller->/** @scrutinizer ignore-call */ 
269
                     install();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
269
    }
270
}
271