Code Duplication    Length = 16-18 lines in 2 locations

src/Subjects/AbstractProductSubject.php 2 locations

@@ 504-519 (lines=16) @@
501
     * @return array The category
502
     * @throws \Exception Is thrown, if the requested category is not available
503
     */
504
    public function getCategoryByPath($path, $storeViewCode = StoreViewCodes::ADMIN)
505
    {
506
507
        // load the categories by the passed store view code
508
        $categories = $this->getCategoriesByStoreViewCode($storeViewCode);
509
510
        // query whether or not the category with the passed path exists
511
        if (isset($categories[$path])) {
512
            return $categories[$path];
513
        }
514
515
        // throw an exception, if not
516
        throw new \Exception(
517
            $this->appendExceptionSuffix(
518
                sprintf('Can\'t find category with path %s', $path)
519
            )
520
        );
521
    }
522
@@ 544-561 (lines=18) @@
541
     * @return array The category data
542
     * @throws \Exception Is thrown, if the category is not available
543
     */
544
    public function getCategory($categoryId, $storeViewCode = StoreViewCodes::ADMIN)
545
    {
546
547
        // retrieve the categories with for the passed store view code
548
        $categories = $this->getCategoriesByStoreViewCode($storeViewCode);
549
550
        // try to load the category with the passed ID
551
        foreach ($categories as $category) {
552
            if ($category[MemberNames::ENTITY_ID] == $categoryId) {
553
                return $category;
554
            }
555
        }
556
557
        // throw an exception if the category is NOT available
558
        throw new \Exception(
559
            $this->appendExceptionSuffix(
560
                sprintf('Can\'t load category with ID %d', $categoryId)
561
            )
562
        );
563
    }
564