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