Passed
Push — master ( 32db04...fadd64 )
by Vasyl
02:53
created

Variable::booted()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 2
nc 1
nop 0
1
<?php
2
3
namespace Fomvasss\Variable\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Variable extends Model
8
{
9
    public $table = 'variables';
10
11
    public $timestamps = false;
12
13
    public $guarded = ['id'];
14
15
    public function __construct(array $attributes = [])
16
    {
17
        parent::__construct($attributes);
18
19
        $this->setTable(config('variables.table_name'));
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

19
        $this->setTable(/** @scrutinizer ignore-call */ config('variables.table_name'));
Loading history...
20
    }
21
22
    protected static function booted()
23
    {
24
        static::saved(function ($model) {
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed. ( Ignorable by Annotation )

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

24
        static::saved(function (/** @scrutinizer ignore-unused */ $model) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
            if (config('variables.cache.autoclear')) {
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

25
            if (/** @scrutinizer ignore-call */ config('variables.cache.autoclear')) {
Loading history...
26
                app(\Fomvasss\Variable\VariableManagerContract::class)->cacheClear();
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

26
                /** @scrutinizer ignore-call */ 
27
                app(\Fomvasss\Variable\VariableManagerContract::class)->cacheClear();
Loading history...
27
            }
28
        });
29
    }
30
31
    public function byLangcode($query, ?string $langcode = null)
32
    {
33
        return $query->when($langcode, function ($q) use ($langcode) {
34
           $q->where('langcode', $langcode);
35
        });
36
    }
37
}
38