Settings   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 58
rs 10
c 0
b 0
f 0
ccs 0
cts 33
cp 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 6 1
A load() 0 11 3
A cssClassProvider() 0 4 1
A getCssClass() 0 4 1
A getCssClasses() 0 10 2
1
<?php
2
/**
3
 * Pluggable themes for Yii2
4
 *
5
 * @link      https://github.com/hiqdev/yii2-thememanager
6
 * @package   yii2-thememanager
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\thememanager\models;
12
13
class Settings extends \yii\base\Model implements OrientationInterface
14
{
15
    /**
16
     * @var string theme name
17
     */
18
    public $theme;
19
20
    public function rules()
21
    {
22
        return [
23
            [['theme'], 'safe'],
24
        ];
25
    }
26
27
    /**
28
     * @var array default values for attributes
29
     */
30
    protected $_defaults = [];
31
32
    public function load($data = null, $formName = '')
33
    {
34
        parent::load($data, $formName);
35
        foreach ($this->_defaults as $k => $v) {
36
            if (is_null($this->$k)) {
37
                $this->$k = $v;
38
            }
39
        }
40
41
        return true;
42
    }
43
44
    /**
45
     * Default css provider - returns plain value, fits for attributes like skin and layout.
46
     * @param $name  string         attribute name
47
     * @param $value boolean|string attribute value
48
     * @return string css class
49
     */
50
    public static function cssClassProvider($name, $value)
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed.

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

Loading history...
51
    {
52
        return $value;
53
    }
54
55
    public function getCssClass($name)
56
    {
57
        return static::cssClassProvider($name, $this->$name);
58
    }
59
60
    public function getCssClasses(array $names)
61
    {
62
        $classes = [];
63
64
        foreach ($names as $n) {
65
            $classes[$n] = $this->getCssClass($n);
66
        }
67
68
        return implode(' ', array_filter($classes));
69
    }
70
}
71