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 | class CategoryUrlPathChecker implements UrlPathUsedChecker |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var CategoryResolverInterface |
||
| 16 | */ |
||
| 17 | private $categoryResolver; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var StoreManagerInterface |
||
| 21 | */ |
||
| 22 | private $storeManager; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param CategoryResolverInterface $categoryResolver |
||
| 26 | * @param StoreManagerInterface $storeManager |
||
| 27 | */ |
||
| 28 | public function __construct(CategoryResolverInterface $categoryResolver, StoreManagerInterface $storeManager) |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param UrlPath $urlPath |
||
| 36 | * @param int $storeId |
||
| 37 | * |
||
| 38 | * @return EntityData[] |
||
| 39 | */ |
||
| 40 | public function check(UrlPath $urlPath, int $storeId) : array |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @param UrlPath $urlPath |
||
| 49 | * @param int $storeId |
||
| 50 | * |
||
| 51 | * @return int |
||
| 52 | */ |
||
| 53 | View Code Duplication | private function resolveParentCategoryId(UrlPath $urlPath, int $storeId) : int |
|
| 63 | } |
||
| 64 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.