Code Duplication    Length = 7-11 lines in 4 locations

src/Observers/UrlRewriteObserver.php 4 locations

@@ 177-187 (lines=11) @@
174
        // try to load the entity ID for the product with the passed SKU
175
        if ($product = $this->loadProduct($sku = $this->getValue(ColumnKeys::SKU))) {
176
            $this->setLastEntityId($this->entityId = $product[MemberNames::ENTITY_ID]);
177
        } else {
178
            // prepare a log message
179
            $message = sprintf('Product with SKU "%s" can\'t be loaded to create URL rewrites', $sku);
180
            // query whether or not we're in debug mode
181
            if ($this->getSubject()->isDebugMode()) {
182
                $this->getSubject()->getSystemLogger()->warning($message);
183
                return $this->getRow();
184
            } else {
185
                throw new \Exception($this->appendExceptionSuffix($message));
186
            }
187
        }
188
189
        // try to load the URL key
190
        if ($this->hasValue(ColumnKeys::URL_KEY)) {
@@ 192-202 (lines=11) @@
189
        // try to load the URL key
190
        if ($this->hasValue(ColumnKeys::URL_KEY)) {
191
            $this->urlKey = $this->getValue(ColumnKeys::URL_KEY);
192
        } else {
193
            // prepare a log message
194
            $message = sprintf('Can\'t find a value in column "url_key" for product with SKU "%s"', $sku);
195
            // query whether or not we're in debug mode
196
            if ($this->getSubject()->isDebugMode()) {
197
                $this->getSubject()->getSystemLogger()->warning($message);
198
                return $this->getRow();
199
            } else {
200
                throw new \Exception($this->appendExceptionSuffix($message));
201
            }
202
        }
203
204
        // initialize the store view code
205
        $this->getSubject()->prepareStoreViewCode();
@@ 312-318 (lines=7) @@
309
                    $this->persistUrlRewriteProductCategory($urlRewriteProductCategory);
310
                } catch (\Exception $e) {
311
                    // query whether or not debug mode has been enabled
312
                    if ($this->getSubject()->isDebugMode()) {
313
                        $this->getSubject()
314
                             ->getSystemLogger()
315
                             ->warning($this->getSubject()->appendExceptionSuffix($e->getMessage()));
316
                    } else {
317
                        throw $e;
318
                    }
319
                }
320
            }
321
        }
@@ 401-407 (lines=7) @@
398
                $this->resolveCategoryIds($category[MemberNames::ENTITY_ID], true, $storeViewCode);
399
            } catch (\Exception $e) {
400
                // query whether or not debug mode has been enabled
401
                if ($this->getSubject()->isDebugMode()) {
402
                    $this->getSubject()
403
                         ->getSystemLogger()
404
                         ->warning($this->getSubject()->appendExceptionSuffix($e->getMessage()));
405
                } else {
406
                    throw $e;
407
                }
408
            }
409
        }
410