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 | View Code Duplication | class MediaMultipleDirective |
|
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var string |
||
| 9 | */ |
||
| 10 | private $zone; |
||
| 11 | /** |
||
| 12 | * @var |
||
| 13 | */ |
||
| 14 | private $entity; |
||
| 15 | /** |
||
| 16 | * @var string|null |
||
| 17 | */ |
||
| 18 | private $view; |
||
| 19 | |||
| 20 | public function show($arguments) |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Extract the possible arguments as class properties |
||
| 36 | * @param array $arguments |
||
| 37 | */ |
||
| 38 | private function extractArguments(array $arguments) |
||
| 44 | } |
||
| 45 |