Completed
Push — master ( cf838f...441ca2 )
by Dmitry
04:31
created

Osimage   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 7
Bugs 0 Features 1
Metric Value
wmc 14
c 7
b 0
f 1
lcom 3
cbo 2
dl 0
loc 76
ccs 0
cts 49
cp 0
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A attributes() 0 4 1
A rules() 0 4 1
A getFullOsName() 0 4 1
A getSoftPackName() 0 4 2
A getDisplaySoftPackName() 0 4 1
A hasSoftPack() 0 4 1
A getPanelName() 0 4 2
A getSoftPack() 0 4 2
A getDisplayPanelName() 0 8 2
A attributeLabels() 0 9 1
1
<?php
2
3
/*
4
 * Server module for HiPanel
5
 *
6
 * @link      https://github.com/hiqdev/hipanel-module-server
7
 * @package   hipanel-module-server
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
/**
13
 * @link    http://hiqdev.com/hipanel
14
 * @license http://hiqdev.com/hipanel/license
15
 * @copyright Copyright (c) 2015 HiQDev
16
 */
17
18
namespace hipanel\modules\server\models;
19
20
use Yii;
21
22
/**
23
 * @property string osimage
24
 * @property string os
25
 * @property string version
26
 * @property string bitwise
27
 * @property string panel
28
 * @property array softpack
29
 */
30
class Osimage extends \hiqdev\hiart\ActiveRecord
31
{
32
    const NO_PANEL = 'no';
33
34
    /**
35
     * @return array the list of attributes for this record
36
     */
37
    public function attributes()
38
    {
39
        return ['osimage', 'os', 'version', 'bitwise', 'panel', 'softpack'];
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function rules()
46
    {
47
        return [[['osimage'], 'required']];
48
    }
49
50
    /**
51
     * @param string $delimiter defines delimiter to separeate os, version and bitwise of OS
52
     * @return string
53
     */
54
    public function getFullOsName($delimiter = ' ')
55
    {
56
        return implode($delimiter, [$this->os, $this->version, $this->bitwise]);
57
    }
58
59
    public function getSoftPackName()
60
    {
61
        return $this->hasSoftPack() ? $this->softpack['name'] : 'clear';
62
    }
63
64
    public function getDisplaySoftPackName()
65
    {
66
        return Yii::t('hipanel/server/os', $this->getSoftPackName());
67
    }
68
69
    public function hasSoftPack()
70
    {
71
        return !empty($this->softpack);
72
    }
73
74
    public function getPanelName()
75
    {
76
        return $this->panel ?: static::NO_PANEL;
77
    }
78
79
    public function getSoftPack()
80
    {
81
        return $this->hasSoftPack() ? $this->softpack : [];
82
    }
83
84
    public function getDisplayPanelName()
85
    {
86
        $panel = $this->getPanelName();
87
        if ($panel === static::NO_PANEL) {
88
            $panel = 'No panel';
89
        }
90
        return Yii::t('hipanel/server/panel', $panel);
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function attributeLabels()
97
    {
98
        return [
99
            'osimagae' => Yii::t('hipanel/server/os', 'System name of image'),
100
            'os' => Yii::t('hipanel/server/os', 'OS'),
101
            'softpack' => Yii::t('hipanel/server/os', 'Soft package'),
102
            'panel' => Yii::t('hipanel/server/os', 'Panel'),
103
        ];
104
    }
105
}
106