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 | View Code Duplication | class ExampleRow extends AbstractRow |
|
| 9 | { |
||
| 10 | /** |
||
| 11 | * @param string $location |
||
| 12 | * @param int|null $startLine |
||
| 13 | * @param int|null $numberOfLines |
||
| 14 | * @param string|null $description |
||
| 15 | */ |
||
| 16 | public function __construct($location, $startLine = null, $numberOfLines = null, $description = null) |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @return string |
||
| 26 | */ |
||
| 27 | public function getName() |
||
| 31 | } |
||
| 32 |