Variable   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 4
eloc 11
c 2
b 0
f 2
dl 0
loc 28
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A byLangcode() 0 4 1
A booted() 0 5 2
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