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 | View Code Duplication | final class ShowLatestProductAction |
|
| 14 | { |
||
| 15 | /** @var ViewHandlerInterface */ |
||
| 16 | private $viewHandler; |
||
| 17 | |||
| 18 | /** @var ProductLatestViewRepositoryInterface */ |
||
| 19 | private $productLatestQuery; |
||
| 20 | |||
| 21 | public function __construct( |
||
| 28 | |||
| 29 | public function __invoke(Request $request): Response |
||
| 45 | } |
||
| 46 |