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();
@@ 298-304 (lines=7) @@
295
                    $this->persistUrlRewriteProductCategory($urlRewriteProductCategory);
296
                } catch (\Exception $e) {
297
                    // query whether or not debug mode has been enabled
298
                    if ($this->getSubject()->isDebugMode()) {
299
                        $this->getSubject()
300
                             ->getSystemLogger()
301
                             ->warning($this->getSubject()->appendExceptionSuffix($e->getMessage()));
302
                    } else {
303
                        throw $e;
304
                    }
305
                }
306
            }
307
        }
@@ 366-372 (lines=7) @@
363
                $this->resolveCategoryIds($category[MemberNames::ENTITY_ID], true, $storeViewCode);
364
            } catch (\Exception $e) {
365
                // query whether or not debug mode has been enabled
366
                if ($this->getSubject()->isDebugMode()) {
367
                    $this->getSubject()
368
                         ->getSystemLogger()
369
                         ->warning($this->getSubject()->appendExceptionSuffix($e->getMessage()));
370
                } else {
371
                    throw $e;
372
                }
373
            }
374
        }
375