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 |
||
| 5 | class Level |
||
| 6 | { |
||
| 7 | const NONE = 0; // TODO: Get rid of this *level* <[email protected]> |
||
| 8 | const PATCH = 1; |
||
| 9 | const MINOR = 2; |
||
| 10 | const MAJOR = 3; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @param string $order |
||
| 14 | * @return array |
||
| 15 | */ |
||
| 16 | 152 | public static function asList($order = 'asc') |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @param int $level |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | 2 | View Code Duplication | public static function toString($level) |
| 46 | |||
| 47 | /** |
||
| 48 | * @param string $level |
||
| 49 | * @return int |
||
| 50 | */ |
||
| 51 | 4 | View Code Duplication | public static function fromString($level) |
| 62 | } |
||
| 63 |