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 |
||
24 | View Code Duplication | trait OverwriteAction |
|
|
|||
25 | { |
||
26 | /** |
||
27 | * Overwrite action. |
||
28 | * |
||
29 | * @param string $anId The file id |
||
30 | * @param Request $aRequest The request |
||
31 | * @param FileCommandBus $aCommandBus The command bus |
||
32 | * @param string $aProperty The file property that want to get from request |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | public function overwriteAction($anId, Request $aRequest, FileCommandBus $aCommandBus, $aProperty) |
||
59 | } |
||
60 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.