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 |
||
| 37 | class BundleSelectionObserver extends AbstractProductImportObserver |
||
| 38 | { |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Will be invoked by the action on the events the listener has been registered for. |
||
| 42 | * |
||
| 43 | * @param array $row The row to handle |
||
| 44 | * |
||
| 45 | * @return array The modified row |
||
| 46 | * @see \TechDivision\Import\Product\Observers\ImportObserverInterface::handle() |
||
| 47 | */ |
||
| 48 | public function handle(array $row) |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Process the observer's business logic. |
||
| 63 | * |
||
| 64 | * @return array The processed row |
||
| 65 | */ |
||
| 66 | View Code Duplication | protected function process() |
|
| 84 | |||
| 85 | /** |
||
| 86 | * Prepare the attributes of the entity that has to be persisted. |
||
| 87 | * |
||
| 88 | * @return array The prepared attributes |
||
| 89 | */ |
||
| 90 | protected function prepareAttributes() |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Initialize the bundle selection with the passed attributes and returns an instance. |
||
| 134 | * |
||
| 135 | * @param array $attr The bundle selection attributes |
||
| 136 | * |
||
| 137 | * @return array The initialized bundle selection |
||
| 138 | */ |
||
| 139 | protected function initializeBundleSelection(array $attr) |
||
| 143 | |||
| 144 | /** |
||
| 145 | * Return's the last created option ID. |
||
| 146 | * |
||
| 147 | * @return integer $optionId The last created option ID |
||
| 148 | */ |
||
| 149 | protected function getLastOptionId() |
||
| 153 | |||
| 154 | /** |
||
| 155 | * Save's the mapping of the child SKU and the selection ID. |
||
| 156 | * |
||
| 157 | * @param string $childSku The child SKU of the selection |
||
| 158 | * @param integer $selectionId The selection ID to save |
||
| 159 | * |
||
| 160 | * @return void |
||
| 161 | */ |
||
| 162 | protected function addChildSkuSelectionIdMapping($childSku, $selectionId) |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Returns the acutal value of the position counter and raise's it by one. |
||
| 169 | * |
||
| 170 | * @return integer The actual value of the position counter |
||
| 171 | */ |
||
| 172 | protected function raisePositionCounter() |
||
| 176 | |||
| 177 | /** |
||
| 178 | * Return's the option ID for the passed name. |
||
| 179 | * |
||
| 180 | * @param string $name The name to return the option ID for |
||
| 181 | * |
||
| 182 | * @return integer The option ID for the passed name |
||
| 183 | * @throws \Exception Is thrown, if no option ID for the passed name is available |
||
| 184 | */ |
||
| 185 | protected function getOptionIdForName($name) |
||
| 189 | |||
| 190 | /** |
||
| 191 | * Return's the mapping for the passed price type. |
||
| 192 | * |
||
| 193 | * @param string $priceType The price type to map |
||
| 194 | * |
||
| 195 | * @return integer The mapped price type |
||
| 196 | * @throws \Exception Is thrown, if the passed price type can't be mapped |
||
| 197 | */ |
||
| 198 | protected function mapPriceType($priceType) |
||
| 202 | |||
| 203 | /** |
||
| 204 | * Return the entity ID for the passed SKU. |
||
| 205 | * |
||
| 206 | * @param string $sku The SKU to return the entity ID for |
||
| 207 | * |
||
| 208 | * @return integer The mapped entity ID |
||
| 209 | * @throws \Exception Is thrown if the SKU is not mapped yet |
||
| 210 | */ |
||
| 211 | protected function mapSkuToEntityId($sku) |
||
| 215 | |||
| 216 | /** |
||
| 217 | * Persist's the passed product bundle selection data and return's the ID. |
||
| 218 | * |
||
| 219 | * @param array $productBundleSelection The product bundle selection data to persist |
||
| 220 | * |
||
| 221 | * @return string The ID of the persisted entity |
||
| 222 | */ |
||
| 223 | protected function persistProductBundleSelection($productBundleSelection) |
||
| 227 | } |
||
| 228 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.