Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 22 | class Slide extends \yii\db\ActiveRecord |
||
| 23 | { |
||
| 24 | use \app\traits\FindById; |
||
| 25 | |||
| 26 | protected function invalidateSliderTags() |
||
| 33 | |||
| 34 | public function behaviors() |
||
| 42 | /** |
||
| 43 | * @inheritdoc |
||
| 44 | */ |
||
| 45 | public static function tableName() |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @inheritdoc |
||
| 52 | */ |
||
| 53 | View Code Duplication | public function rules() |
|
| 62 | |||
| 63 | /** |
||
| 64 | * @inheritdoc |
||
| 65 | */ |
||
| 66 | public function attributeLabels() |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Search slides |
||
| 83 | * @param $params |
||
| 84 | * @return ActiveDataProvider |
||
| 85 | */ |
||
| 86 | View Code Duplication | public function search($params) |
|
| 105 | |||
| 106 | /** |
||
| 107 | * @return \yii\db\ActiveQuery |
||
| 108 | */ |
||
| 109 | public function getSlider() |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @inheritdoc |
||
| 116 | */ |
||
| 117 | public function afterSave($insert, $changedAttributes) |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @inheritdoc |
||
| 125 | */ |
||
| 126 | public function afterDelete() |
||
| 131 | } |
||
| 132 |