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 |
||
16 | class SliderHandler extends \yii\db\ActiveRecord |
||
17 | { |
||
18 | private static $identity_map = []; |
||
19 | |||
20 | use \app\traits\FindById; |
||
21 | |||
22 | public function behaviors() |
||
30 | /** |
||
31 | * @inheritdoc |
||
32 | */ |
||
33 | public static function tableName() |
||
37 | |||
38 | /** |
||
39 | * @inheritdoc |
||
40 | */ |
||
41 | public function rules() |
||
47 | |||
48 | /** |
||
49 | * @inheritdoc |
||
50 | */ |
||
51 | public function attributeLabels() |
||
60 | /** |
||
61 | * Returns model using indentity map and cache |
||
62 | * @param string $id |
||
63 | * @return SliderHandler|null |
||
64 | */ |
||
65 | View Code Duplication | public static function findBySliderId($id) |
|
90 | |||
91 | } |
||
92 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.