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 BundleOptionValueObserver extends AbstractProductImportObserver |
||
| 38 | { |
||
| 39 | |||
| 40 | /** |
||
| 41 | * The option value store mapping. |
||
| 42 | * |
||
| 43 | * @var array |
||
| 44 | */ |
||
| 45 | protected $optionValueStoreMapping = array(); |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Will be invoked by the action on the events the listener has been registered for. |
||
| 49 | * |
||
| 50 | * @param array $row The row to handle |
||
| 51 | * |
||
| 52 | * @return array The modified row |
||
| 53 | * @see \TechDivision\Import\Product\Observers\ImportObserverInterface::handle() |
||
| 54 | */ |
||
| 55 | public function handle(array $row) |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Process the observer's business logic. |
||
| 70 | * |
||
| 71 | * @return array The processed row |
||
| 72 | */ |
||
| 73 | protected function process() |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Prepare the attributes of the entity that has to be persisted. |
||
| 102 | * |
||
| 103 | * @return array The prepared attributes |
||
| 104 | */ |
||
| 105 | View Code Duplication | protected function prepareAttributes() |
|
| 127 | |||
| 128 | /** |
||
| 129 | * Initialize the bundle option value with the passed attributes and returns an instance. |
||
| 130 | * |
||
| 131 | * @param array $attr The bundle option value attributes |
||
| 132 | * |
||
| 133 | * @return array The initialized bundle option value |
||
| 134 | */ |
||
| 135 | protected function initializeBundleOptionValue(array $attr) |
||
| 139 | |||
| 140 | /** |
||
| 141 | * Add the store => option mapping. |
||
| 142 | * |
||
| 143 | * @param integer $optionId The option ID to map |
||
| 144 | * @param integer $storeId The store ID to map |
||
| 145 | * |
||
| 146 | * @return void |
||
| 147 | */ |
||
| 148 | protected function addOptionValueStoreMapping($optionId, $storeId) |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Query whether or not the passed option/store ID combination has already been mapped. |
||
| 155 | * |
||
| 156 | * @param integer $optionId The option ID to map |
||
| 157 | * @param integer $storeId The store ID to map |
||
| 158 | * |
||
| 159 | * @return boolean TRUE if the combination has already been mapped, else FALSE |
||
| 160 | */ |
||
| 161 | protected function isMapped($optionId, $storeId) |
||
| 165 | |||
| 166 | /** |
||
| 167 | * Return's the last created option ID. |
||
| 168 | * |
||
| 169 | * @return integer $optionId The last created option ID |
||
| 170 | */ |
||
| 171 | protected function getLastOptionId() |
||
| 175 | |||
| 176 | /** |
||
| 177 | * Return's the option ID for the passed name. |
||
| 178 | * |
||
| 179 | * @param string $name The name to return the option ID for |
||
| 180 | * |
||
| 181 | * @return integer The option ID for the passed name |
||
| 182 | * @throws \Exception Is thrown, if no option ID for the passed name is available |
||
| 183 | */ |
||
| 184 | protected function getOptionIdForName($name) |
||
| 188 | |||
| 189 | /** |
||
| 190 | * Return's the store for the passed store code. |
||
| 191 | * |
||
| 192 | * @param string $storeCode The store code to return the store for |
||
| 193 | * |
||
| 194 | * @return array The requested store |
||
| 195 | * @throws \Exception Is thrown, if the requested store is not available |
||
| 196 | */ |
||
| 197 | protected function getStoreByStoreCode($storeCode) |
||
| 201 | |||
| 202 | /** |
||
| 203 | * Persist's the passed product bundle option value data. |
||
| 204 | * |
||
| 205 | * @param array $productBundleOptionValue The product bundle option value data to persist |
||
| 206 | * |
||
| 207 | * @return void |
||
| 208 | */ |
||
| 209 | protected function persistProductBundleOptionValue($productBundleOptionValue) |
||
| 213 | } |
||
| 214 |
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.