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 | 2 | class Gateway extends AbstractChecker |
|
| 14 | { |
||
| 15 | 2 | /** |
|
| 16 | 2 | * @var string |
|
| 17 | 2 | */ |
|
| 18 | 2 | protected $target = 'url'; |
|
| 19 | 2 | ||
| 20 | /** |
||
| 21 | * @param string $target |
||
| 22 | 2 | * @param array $options |
|
| 23 | * |
||
| 24 | 2 | * @return boolean |
|
| 25 | */ |
||
| 26 | protected function curl($target, array $options = []) |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param string $target |
||
| 42 | * @param boolean $expectExists |
||
| 43 | * @param array $task |
||
| 44 | * |
||
| 45 | * @throws FailException |
||
| 46 | * @throws SuccessException |
||
| 47 | */ |
||
| 48 | View Code Duplication | protected function testExists($target, $expectExists, array $task) |
|
| 60 | } |
||
| 61 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.