DefaultLayout   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 7 1
A getColumnOpts() 0 11 1
A getRegions() 0 8 2
1
<?php
2
3
namespace cornernote\dashboard\layouts;
4
5
use cornernote\dashboard\Layout;
6
use cornernote\dashboard\models\DashboardPanel;
7
use Yii;
8
9
/**
10
 * DefaultLayout
11
 * @package cornernote\dashboard\layouts
12
 */
13
class DefaultLayout extends Layout
14
{
15
16
    /**
17
     * @var int
18
     */
19
    public $columns = 1;
20
21
    /**
22
     * @var string
23
     */
24
    public $viewPath = '@cornernote/dashboard/views/dashboard/layouts/default';
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function rules()
30
    {
31
        return [
32
            [['columns'], 'required'],
33
            [['columns'], 'integer'],
34
        ];
35
    }
36
37
    /**
38
     * @return array
39
     */
40
    public static function getColumnOpts()
41
    {
42
        return [
43
            '1' => 1,
44
            '2' => 2,
45
            '3' => 3,
46
            '4' => 4,
47
            '6' => 6,
48
            '12' => 12,
49
        ];
50
    }
51
52
    /**
53
     * @return array
54
     */
55
    public function getRegions()
56
    {
57
        $regions = [];
58
        for ($i = 1; $i <= $this->columns; $i++) {
59
            $regions['column-' . $i] = Yii::t('dashboard', 'Column {i}', ['i' => $i]);
60
        }
61
        return $regions;
62
    }
63
64
}