AuthItemSearch   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 45
c 0
b 0
f 0
ccs 10
cts 12
cp 0.8333
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 6 1
A search() 0 26 3
1
<?php
2
3
namespace app\modules\admin\models\search;
4
5
use yii\data\ActiveDataProvider;
6
use app\models\entity\AuthItem;
7
8
/**
9
 * AuthItemSearch represents the model behind the search form about `app\models\entity\AuthItem`
10
 */
11
class AuthItemSearch extends AuthItem
12
{
13
    /**
14
     * @inheritdoc
15
     */
16 4
    public function rules()
17
    {
18
        return [
19 4
            ['name', 'string'],
20
        ];
21
    }
22
23
    /**
24
     * Search by request criteria
25
     *
26
     * @param array|null Filter params
27
     * @return ActiveDataProvider Data provider
28
     */
29 4
    public function search($params)
30
    {
31 4
        $query = AuthItem::find();
32
33 4
        $dataProvider = new ActiveDataProvider([
34 4
            'query' => $query,
35
            'sort' => [
36
                'defaultOrder' => [
37 4
                    'name' => SORT_ASC,
38
                ]
39
            ],
40
            'pagination' => [
41
                'pageSize' => 50,
42
            ],
43
        ]);
44
45 4
        $query->andFilterWhere(['type' => \yii\rbac\Item::TYPE_ROLE]);
46
47 4
        if (!($this->load($params) && $this->validate())) {
48 4
            return $dataProvider;
49
        }
50
51
        $query->andFilterWhere(['like', 'name', $this->name]);
52
53
        return $dataProvider;
54
    }
55
}
56