Code Duplication    Length = 7-11 lines in 4 locations

src/Observers/UrlRewriteObserver.php 4 locations

@@ 146-156 (lines=11) @@
143
        // try to load the entity ID for the product with the passed SKU
144
        if ($product = $this->loadProduct($sku = $this->getValue(ColumnKeys::SKU))) {
145
            $this->setLastEntityId($this->entityId = $product[MemberNames::ENTITY_ID]);
146
        } else {
147
            // prepare a log message
148
            $message = sprintf('Product with SKU "%s" can\'t be loaded to create URL rewrites', $sku);
149
            // query whether or not we're in debug mode
150
            if ($this->getSubject()->isDebugMode()) {
151
                $this->getSubject()->getSystemLogger()->warning($message);
152
                return $this->getRow();
153
            } else {
154
                throw new \Exception($this->appendExceptionSuffix($message));
155
            }
156
        }
157
158
        // try to load the URL key
159
        if ($this->hasValue(ColumnKeys::URL_KEY)) {
@@ 161-171 (lines=11) @@
158
        // try to load the URL key
159
        if ($this->hasValue(ColumnKeys::URL_KEY)) {
160
            $this->urlKey = $this->getValue(ColumnKeys::URL_KEY);
161
        } else {
162
            // prepare a log message
163
            $message = sprintf('Can\'t find a value in column "url_key" for product with SKU "%s"', $sku);
164
            // query whether or not we're in debug mode
165
            if ($this->getSubject()->isDebugMode()) {
166
                $this->getSubject()->getSystemLogger()->warning($message);
167
                return $this->getRow();
168
            } else {
169
                throw new \Exception($this->appendExceptionSuffix($message));
170
            }
171
        }
172
173
        // initialize the store view code
174
        $this->getSubject()->prepareStoreViewCode();
@@ 281-287 (lines=7) @@
278
                    $this->persistUrlRewriteProductCategory($urlRewriteProductCategory);
279
                } catch (\Exception $e) {
280
                    // query whether or not debug mode has been enabled
281
                    if ($this->getSubject()->isDebugMode()) {
282
                        $this->getSubject()
283
                             ->getSystemLogger()
284
                             ->warning($this->getSubject()->appendExceptionSuffix($e->getMessage()));
285
                    } else {
286
                        throw $e;
287
                    }
288
                }
289
            }
290
        }
@@ 372-378 (lines=7) @@
369
                $this->resolveCategoryIds($category[MemberNames::ENTITY_ID], true, $storeViewCode);
370
            } catch (\Exception $e) {
371
                // query whether or not debug mode has been enabled
372
                if ($this->getSubject()->isDebugMode()) {
373
                    $this->getSubject()
374
                         ->getSystemLogger()
375
                         ->warning($this->getSubject()->appendExceptionSuffix($e->getMessage()));
376
                } else {
377
                    throw $e;
378
                }
379
            }
380
        }
381