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 PlanQuery extends \hiqdev\hiart\ActiveQuery |
||
17 | { |
||
18 | public function byId($id) |
||
22 | |||
23 | /** |
||
24 | * @param null $db |
||
25 | * @return Plan|null |
||
26 | */ |
||
27 | public function one($db = null) |
||
31 | |||
32 | /** |
||
33 | * @param null $db |
||
34 | * @return Plan[] |
||
35 | */ |
||
36 | public function all($db = null) |
||
40 | |||
41 | View Code Duplication | public function withPrices() |
|
52 | |||
53 | View Code Duplication | public function joinWithPrices() |
|
64 | } |
||
65 |