Code Duplication    Length = 55-55 lines in 2 locations

src/modules/prototype/models/search/Html.php 1 location

@@ 13-67 (lines=55) @@
10
/**
11
 * Html represents the model behind the search form about `app\modules\prototype\models\Html`.
12
 */
13
class Html extends HtmlModel
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function rules()
19
    {
20
        return [
21
            [['id'], 'integer'],
22
            [['key', 'value'], '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 = HtmlModel::find();
45
46
        $dataProvider = new ActiveDataProvider(
47
            [
48
                'query' => $query,
49
            ]
50
        );
51
52
        $this->load($params);
53
54
        if (!$this->validate()) {
55
            // uncomment the following line if you do not want to any records when validation fails
56
            // $query->where('0=1');
57
            return $dataProvider;
58
        }
59
60
        $query->andFilterWhere(
61
            [
62
                'id' => $this->id,
63
            ]
64
        );
65
66
        $query->andFilterWhere(['like', 'key', $this->key])
67
            ->andFilterWhere(['like', 'value', $this->value]);
68
69
        return $dataProvider;
70
    }

src/modules/prototype/models/search/Less.php 1 location

@@ 13-67 (lines=55) @@
10
/**
11
 * Less represents the model behind the search form about `app\modules\prototype\models\Less`.
12
 */
13
class Less extends LessModel
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function rules()
19
    {
20
        return [
21
            [['id'], 'integer'],
22
            [['key', 'value'], '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 = LessModel::find();
45
46
        $dataProvider = new ActiveDataProvider(
47
            [
48
                'query' => $query,
49
            ]
50
        );
51
52
        $this->load($params);
53
54
        if (!$this->validate()) {
55
            // uncomment the following line if you do not want to any records when validation fails
56
            // $query->where('0=1');
57
            return $dataProvider;
58
        }
59
60
        $query->andFilterWhere(
61
            [
62
                'id' => $this->id,
63
            ]
64
        );
65
66
        $query->andFilterWhere(['like', 'key', $this->key])
67
            ->andFilterWhere(['like', 'value', $this->value]);
68
69
        return $dataProvider;
70
    }