GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — filters ( 4f5140...7db5de )
by
unknown
12:50
created

ContentBlockGroup::getNameWithCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace app\modules\core\models;
4
5
use devgroup\TagDependencyHelper\ActiveRecordHelper;
6
use Yii;
7
8
/**
9
 * This is the model class for table "{{%content_block_group}}".
10
 *
11
 * @property integer $id
12
 * @property integer $parent_id
13
 * @property string $name
14
 * @property integer $sort_order
15
 * @property ContentBlockGroup[] $child
16
 * @property ContentBlock[] $contentBlocks
17
 */
18
class ContentBlockGroup extends \yii\db\ActiveRecord
19
{
20
21
    const DEFAULT_PARENT_ID = 1;
22
    const DELETE_METHOD_ALL = 1;
23
    const DELETE_METHOD_PARENT_ROOT = 2;
24
25
    public $deleteMethod = null;
26
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public static function tableName()
32
    {
33
        return '{{%content_block_group}}';
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function behaviors()
40
    {
41
        return [
42
            [
43
                'class' => ActiveRecordHelper::className(),
44
            ],
45
        ];
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51
    public function rules()
52
    {
53
        return [
54
            [['parent_id', 'sort_order', 'deleteMethod'], 'integer'],
55
            [['name', 'sort_order', 'parent_id'], 'required'],
56
            [['name'], 'string', 'max' => 250],
57
            [['sort_order'], 'default', 'value' => 0],
58
            [['parent_id'], 'default', 'value' => self::DEFAULT_PARENT_ID],
59
            [['deleteMethod'], 'in', 'range' => [self::DELETE_METHOD_ALL, self::DELETE_METHOD_PARENT_ROOT]]
60
        ];
61
    }
62
63
    /**
64
     * @inheritdoc
65
     */
66
    public function attributeLabels()
67
    {
68
        return [
69
            'id' => Yii::t('app', 'ID'),
70
            'parent_id' => Yii::t('app', 'Parent ID'),
71
            'name' => Yii::t('app', 'Name'),
72
            'sort_order' => Yii::t('app', 'Sort Order'),
73
            'deleteMethod' => Yii::t('app', 'Delete Method'),
74
        ];
75
    }
76
77
    /**
78
     * @return ContentBlockGroup[]
79
     */
80
    public function getChild()
81
    {
82
        return $this->hasMany(ContentBlockGroup::className(), ['parent_id' => 'id']);
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
83
    }
84
85
    /**
86
     * @return ContentBlock[]
87
     */
88
    public function getContentBlocks()
89
    {
90
        return $this->hasMany(ContentBlock::className(), ['group_id' => 'id']);
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function getNameWithCount()
97
    {
98
        return $this->name . ' (' . ContentBlockGroup::find()->where(['group_id' => $this->id])->count() . ')';
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
99
    }
100
101
    /**
102
     * @param $id
103
     * @return null|static
104
     */
105
    public static function findById($id)
106
    {
107
        return self::findOne(['id' => $id]);
108
    }
109
110
    /**
111
     * @return bool
112
     */
113
    public function beforeDelete()
114
    {
115
        if ($this->id == 1) {
116
            return false;
117
        }
118
119
        return parent::beforeDelete();
120
    }
121
122
    /**
123
     * @throws \Exception
124
     */
125
    public function afterDelete()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
126
    {
127
        foreach ($this->child as $model) {
128
            $model->delete();
129
        }
130
131
        foreach ($this->contentBlocks as $block) {
132
            if ($this->deleteMethod == self::DELETE_METHOD_ALL) {
133
                $block->delete();
134
            } else {
135
                $block->group_id = self::DEFAULT_PARENT_ID;
136
                $block->save();
137
            }
138
        }
139
        return parent::afterDelete();
140
    }
141
142
}
143