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 |
||
| 14 | View Code Duplication | class History extends \Model |
|
| 15 | { |
||
| 16 | public static $cols = [ |
||
| 17 | 'currency_exchangerate_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'rate'], |
||
| 18 | 'old' => ['type' => 'decimal'], |
||
| 19 | 'new' => ['type' => 'decimal'], |
||
| 20 | 'date_create' => ['type' => 'dateTime'] |
||
| 21 | ]; |
||
| 22 | |||
| 23 | public static function relations() |
||
| 32 | |||
| 33 | } |
||
| 34 |