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 |
||
| 13 | class HeaderLocation extends AbstractLocation |
||
| 14 | { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Set the name of the location |
||
| 18 | * |
||
| 19 | * @param string $locationName |
||
| 20 | */ |
||
| 21 | 2 | public function __construct($locationName = 'header') |
|
| 25 | |||
| 26 | /** |
||
| 27 | * @param CommandInterface $command |
||
| 28 | * @param RequestInterface $request |
||
| 29 | * @param Parameter $param |
||
| 30 | * |
||
| 31 | * @return MessageInterface |
||
| 32 | */ |
||
| 33 | 1 | public function visit( |
|
| 42 | |||
| 43 | /** |
||
| 44 | * @param CommandInterface $command |
||
| 45 | * @param RequestInterface $request |
||
| 46 | * @param Operation $operation |
||
| 47 | * |
||
| 48 | * @return RequestInterface |
||
| 49 | */ |
||
| 50 | 1 | public function after( |
|
| 67 | } |
||
| 68 |