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 BundleOptionObserver 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() |
|
| 89 | |||
| 90 | /** |
||
| 91 | * Prepare the attributes of the entity that has to be persisted. |
||
| 92 | * |
||
| 93 | * @return array The prepared attributes |
||
| 94 | */ |
||
| 95 | View Code Duplication | protected function prepareAttributes() |
|
| 119 | |||
| 120 | /** |
||
| 121 | * Initialize the bundle option with the passed attributes and returns an instance. |
||
| 122 | * |
||
| 123 | * @param array $attr The bundle option attributes |
||
| 124 | * |
||
| 125 | * @return array The initialized bundle option |
||
| 126 | */ |
||
| 127 | protected function initializeBundleOption(array $attr) |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Reset the position counter to 1. |
||
| 134 | * |
||
| 135 | * @return void |
||
| 136 | */ |
||
| 137 | protected function resetPositionCounter() |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Add's the mapping for the passed name => option ID. |
||
| 144 | * |
||
| 145 | * @param string $name The name of the option |
||
| 146 | * @param integer $optionId The created option ID |
||
| 147 | * |
||
| 148 | * @return void |
||
| 149 | */ |
||
| 150 | protected function addNameOptionIdMapping($name, $optionId) |
||
| 154 | |||
| 155 | /** |
||
| 156 | * Query whether or not the option with the passed name has already been created. |
||
| 157 | * |
||
| 158 | * @param string $name The option name to query for |
||
| 159 | * |
||
| 160 | * @return boolean TRUE if the option already exists, else FALSE |
||
| 161 | */ |
||
| 162 | protected function exists($name) |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Return the entity ID for the passed SKU. |
||
| 169 | * |
||
| 170 | * @param string $sku The SKU to return the entity ID for |
||
| 171 | * |
||
| 172 | * @return integer The mapped entity ID |
||
| 173 | * @throws \Exception Is thrown if the SKU is not mapped yet |
||
| 174 | */ |
||
| 175 | protected function mapSku($sku) |
||
| 176 | { |
||
| 177 | return $this->getSubject()->mapSkuToEntityId($sku); |
||
| 178 | } |
||
| 179 | |||
| 180 | /** |
||
| 181 | * Persist's the passed product bundle option data and return's the ID. |
||
| 182 | * |
||
| 183 | * @param array $productBundleOption The product bundle option data to persist |
||
| 184 | * |
||
| 185 | * @return string The ID of the persisted entity |
||
| 186 | */ |
||
| 187 | protected function persistProductBundleOption($productBundleOption) |
||
| 191 | } |
||
| 192 |
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.