Menu   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 55
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A tableName() 0 4 1
A getChildren() 0 4 1
A getFather() 0 6 1
A rules() 0 9 1
A attributeLabels() 0 10 1
1
<?php
2
3
namespace zacksleo\yii2\cms\models;
4
5
use Yii;
6
use zacksleo\yii2\cms\Module;
7
8
/**
9
 * This is the model class for table "{{%menu}}".
10
 *
11
 * @property integer $id
12
 * @property string $title
13
 * @property integer $order
14
 * @property integer $parent
15
 * @property string $url
16
 * @property Menu[] $children
17
 * @property Menu $father
18
 */
19
class Menu extends \yii\db\ActiveRecord
20
{
21
    /**
22
     * @inheritdoc
23
     */
24 3
    public static function tableName()
25
    {
26 3
        return '{{%menu}}';
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32 2
    public function rules()
33
    {
34
        return [
35 2
            [['title', 'url'], 'required'],
36 2
            ['parent', 'default', 'value' => 0],
37 2
            [['order', 'parent'], 'integer'],
38 2
            [['title', 'url'], 'string', 'max' => 255],
39 2
        ];
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45 1
    public function attributeLabels()
46
    {
47
        return [
48 1
            'id' => Module::t('cms', 'ID'),
49 1
            'title' => Module::t('cms', 'Title'),
50 1
            'order' => Module::t('cms', 'Order'),
51 1
            'parent' => Module::t('cms', 'Parent'),
52 1
            'url' => Module::t('cms', 'Url'),
53 1
        ];
54
    }
55
56
    /**
57
     * @return \yii\db\ActiveQuery
58
     */
59 1
    public function getChildren()
60
    {
61 1
        return $this->hasMany(self::className(), ['parent' => 'id'])->orderBy('order');
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
62
    }
63
64
    /**
65
     * @return \yii\db\ActiveQuery
66
     */
67 1
    public function getFather()
68
    {
69 1
        return $this->hasOne(self::className(), [
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
70
            'id' => 'parent'
71 1
        ]);
72
    }
73
}
74