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 |
||
| 8 | class Class_Method extends Declaration { |
||
| 9 | public $class_name; |
||
| 10 | public $name; |
||
| 11 | public $params; |
||
| 12 | public $static; |
||
| 13 | |||
| 14 | View Code Duplication | function __construct( $path, $line, $class_name, $name, $static ) { |
|
| 21 | |||
| 22 | // TODO: parse "default" into comparable string form? |
||
| 23 | function add_param( $name, $default, $type, $byRef, $variadic ) { |
||
| 26 | |||
| 27 | View Code Duplication | function to_csv_array() { |
|
| 38 | |||
| 39 | function type() { |
||
| 42 | |||
| 43 | function display_name() { |
||
| 47 | } |