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 |
||
34 | View Code Duplication | class LinkAttributePositionUpdateObserver extends LinkAttributePositionObserver |
|
|
|||
35 | { |
||
36 | |||
37 | /** |
||
38 | * Initialize the product link attribute with the passed attributes and returns an instance. |
||
39 | * |
||
40 | * @param array $attr The product link attribute |
||
41 | * |
||
42 | * @return array The initialized product link attribute |
||
43 | */ |
||
44 | protected function initializeProductLinkAttributeInt(array $attr) |
||
60 | |||
61 | /** |
||
62 | * Return's the product link attribute integer value with the passed product link attribute/link ID. |
||
63 | * |
||
64 | * @param integer $productLinkAttributeId The product link attribute ID of the attributes |
||
65 | * @param integer $linkId The link ID of the attribute |
||
66 | * |
||
67 | * @return array The product link attribute integer value |
||
68 | */ |
||
69 | protected function loadProductLinkAttributeInt($productLinkAttributeId, $linkId) |
||
73 | } |
||
74 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.