Completed
Push — master ( 636aa8...197f46 )
by Scott
02:31
created

DriverConfig   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 0
dl 0
loc 59
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDriver() 0 10 2
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
        'driver',
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
     * Find a driver model and set it's values so we can render a form.
53
     *
54
     * @return void
55
     */
56
    public static function getDriver($driverClass)
57
    {
58
        $model = self::firstOrNew(['driver' => $driverClass]);
59
60
        foreach ($model->config as $key => $value) {
61
            $model->$key = $value;
62
        }
63
64
        return $model;
65
    }
66
}
67