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 |
||
| 22 | class SaleLimitMultipleValidator extends ItemHolderValidator |
||
|
|
|||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @var ProductClassRepository |
||
| 26 | */ |
||
| 27 | protected $productClassRepository; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * StockProcessor constructor. |
||
| 31 | * |
||
| 32 | * @param ProductClassRepository $productClassRepository |
||
| 33 | */ |
||
| 34 | 63 | public function __construct(ProductClassRepository $productClassRepository) |
|
| 38 | |||
| 39 | /** |
||
| 40 | * @param ItemHolderInterface $itemHolder |
||
| 41 | * @param PurchaseContext $context |
||
| 42 | * |
||
| 43 | * @throws \Eccube\Service\PurchaseFlow\InvalidItemException |
||
| 44 | */ |
||
| 45 | 54 | public function validate(ItemHolderInterface $itemHolder, PurchaseContext $context) |
|
| 70 | |||
| 71 | View Code Duplication | protected function formatProductName(ProductClass $ProductClass) |
|
| 83 | } |
||
| 84 |