Code Duplication    Length = 16-18 lines in 2 locations

src/Subjects/AbstractProductSubject.php 2 locations

@@ 485-500 (lines=16) @@
482
     * @return array The category
483
     * @throws \Exception Is thrown, if the requested category is not available
484
     */
485
    public function getCategoryByPath($path, $storeViewCode = StoreViewCodes::ADMIN)
486
    {
487
488
        // load the categories by the passed store view code
489
        $categories = $this->getCategoriesByStoreViewCode($storeViewCode);
490
491
        // query whether or not the category with the passed path exists
492
        if (isset($categories[$path])) {
493
            return $categories[$path];
494
        }
495
496
        // throw an exception, if not
497
        throw new \Exception(
498
            $this->appendExceptionSuffix(
499
                sprintf('Can\'t find category with path %s', $path)
500
            )
501
        );
502
    }
503
@@ 537-554 (lines=18) @@
534
     * @return array The category data
535
     * @throws \Exception Is thrown, if the category is not available
536
     */
537
    public function getCategory($categoryId, $storeViewCode = StoreViewCodes::ADMIN)
538
    {
539
540
        // retrieve the categories with for the passed store view code
541
        $categories = $this->getCategoriesByStoreViewCode($storeViewCode);
542
543
        // try to load the category with the passed ID
544
        foreach ($categories as $category) {
545
            if ($category[MemberNames::ENTITY_ID] == $categoryId) {
546
                return $category;
547
            }
548
        }
549
550
        // throw an exception if the category is NOT available
551
        throw new \Exception(
552
            $this->appendExceptionSuffix(
553
                sprintf('Can\'t load category with ID %d', $categoryId)
554
            )
555
        );
556
    }
557