Conditions | 2 |
Paths | 2 |
Total Lines | 29 |
Code Lines | 12 |
Lines | 26 |
Ratio | 89.66 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 | } |
||
71 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.