DriverConfig::getConfig()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 3
nc 4
nop 0
1
<?php namespace Bedard\Shop\Models;
2
3
use Model;
4
5
/**
6
 * DriverConfig Model.
7
 */
8
class DriverConfig extends Model
9
{
10
    use \October\Rain\Database\Traits\Encryptable;
11
12
    /**
13
     * @var string The database table used by the model.
14
     */
15
    public $table = 'bedard_shop_driver_configs';
16
17
    /**
18
     * @var array Default attributes
19
     */
20
    public $attributes = [
21
        'config' => '',
22
    ];
23
24
    /**
25
     * @var array Encrypted fields
26
     */
27
    protected $encryptable = [
28
        'config',
29
    ];
30
31
    /**
32
     * @var array Fillable fields
33
     */
34
    protected $fillable = [
35
        'class',
36
        'config',
37
    ];
38
39
    /**
40
     * @var array Guarded fields
41
     */
42
    protected $guarded = ['*'];
43
44
    /**
45
     * @var array Jsonable fields
46
     */
47
    protected $jsonable = [
48
        'config',
49
    ];
50
51
    /**
52
     * Get the model's config array.
53
     *
54
     * @return array
55
     */
56
    public function getConfig()
57
    {
58
        $config = $this->config ?: [];
59
60
        return is_string($config) ? json_decode($config, true) : $config;
61
    }
62
63
    /**
64
     * Populate attriutes based on config so a form can be rendered.
65
     *
66
     * @param  string   $class
0 ignored issues
show
Bug introduced by
There is no parameter named $class. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
67
     * @return void
68
     */
69
    public function populate()
70
    {
71
        $config = $this->getConfig();
72
73
        foreach ($config as $key => $value) {
74
            $this->$key = $value;
75
        }
76
    }
77
}
78