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 | View Code Duplication | class Param extends \Model |
|
| 17 | { |
||
| 18 | public static $cols = [ |
||
| 19 | 'reward_trigger_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'trigger'], |
||
| 20 | 'param' => ['type' => 'text'], |
||
| 21 | 'value' => ['type' => 'text'], |
||
| 22 | ]; |
||
| 23 | |||
| 24 | public static function relations() |
||
| 33 | |||
| 34 | } |
||
| 35 |