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 |
||
| 14 | View Code Duplication | final class CompleteOrderAction |
|
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var ViewHandlerInterface |
||
| 18 | */ |
||
| 19 | private $viewHandler; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var CommandBus |
||
| 23 | */ |
||
| 24 | private $bus; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param ViewHandlerInterface $viewHandler |
||
| 28 | * @param CommandBus $bus |
||
| 29 | */ |
||
| 30 | public function __construct(ViewHandlerInterface $viewHandler, CommandBus $bus) |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param Request $request |
||
| 38 | * |
||
| 39 | * @return Response |
||
| 40 | */ |
||
| 41 | public function __invoke(Request $request) |
||
| 51 | } |
||
| 52 |