MailerDomainSearch   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 15
dl 0
loc 55
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A scenarios() 0 4 1
A rules() 0 5 1
A search() 0 26 2
1
<?php
2
3
namespace backend\models\search;
4
5
use Yii;
6
use yii\base\Model;
7
use yii\data\ActiveDataProvider;
8
use backend\models\MailerDomain;
9
10
/**
11
 * MailerDomainSearch represents the model behind the search form of `backend\models\MailerDomain`.
12
 */
13
class MailerDomainSearch extends MailerDomain
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function rules()
19
    {
20
        return [
21
            [['id'], 'integer'],
22
            [['name'], 'safe'],
23
        ];
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function scenarios()
30
    {
31
        // bypass scenarios() implementation in the parent class
32
        return Model::scenarios();
33
    }
34
35
    /**
36
     * Creates data provider instance with search query applied
37
     *
38
     * @param array $params
39
     *
40
     * @return ActiveDataProvider
41
     */
42
    public function search($params)
43
    {
44
        $query = MailerDomain::find();
45
46
        // add conditions that should always apply here
47
48
        $dataProvider = new ActiveDataProvider([
49
            'query' => $query,
50
        ]);
51
52
        $this->load($params);
53
54
        if (!$this->validate()) {
55
            // uncomment the following line if you do not want to return any records when validation fails
56
            // $query->where('0=1');
57
            return $dataProvider;
58
        }
59
60
        // grid filtering conditions
61
        $query->andFilterWhere([
62
            'id' => $this->id,
63
        ]);
64
65
        $query->andFilterWhere(['like', 'name', $this->name]);
66
67
        return $dataProvider;
68
    }
69
}
70