Code Duplication    Length = 25-26 lines in 2 locations

Components/Helper.php 2 locations

@@ 106-131 (lines=26) @@
103
     * @param int $mode
104
     * @return null|ProductDetail
105
     */
106
    public function getArticleDetailModelByProduct(Product $product, $mode = Query::HYDRATE_OBJECT)
107
    {
108
        $builder = $this->manager->createQueryBuilder();
109
        $builder->select(['ba', 'd']);
110
        $builder->from('Shopware\CustomModels\Connect\Attribute', 'ba');
111
        $builder->join('ba.articleDetail', 'd');
112
        $builder->leftJoin('d.attribute', 'at');
113
        $builder->where('ba.shopId = :shopId AND ba.sourceId = :sourceId');
114
115
        $query = $builder->getQuery();
116
        $query->setParameter('shopId', $product->shopId);
117
        $query->setParameter('sourceId', (string) $product->sourceId);
118
119
        $result = $query->getResult(
120
            $mode
121
        );
122
123
        if (isset($result[0])) {
124
            /** @var \Shopware\CustomModels\Connect\Attribute $attribute */
125
            $attribute = $result[0];
126
127
            return $attribute->getArticleDetail();
128
        }
129
130
        return null;
131
    }
132
133
    /**
134
     * Get article detail by his number
@@ 702-726 (lines=25) @@
699
     * @param int $mode
700
     * @return null|ProductModel
701
     */
702
    public function getArticleByRemoteProduct(Product $product, $mode = Query::HYDRATE_OBJECT)
703
    {
704
        $builder = $this->manager->createQueryBuilder();
705
        $builder->select(['ba', 'd']);
706
        $builder->from('Shopware\CustomModels\Connect\Attribute', 'ba');
707
        $builder->join('ba.articleDetail', 'd');
708
        $builder->leftJoin('d.attribute', 'at');
709
710
        $builder->where('ba.groupId = :groupId AND ba.isMainVariant = 1 AND ba.shopId = :shopId');
711
        $query = $builder->getQuery();
712
713
        $query->setParameter('groupId', $product->groupId);
714
        $query->setParameter('shopId', $product->shopId);
715
        $result = $query->getResult(
716
            $mode
717
        );
718
719
        if (isset($result[0])) {
720
            /** @var \Shopware\CustomModels\Connect\Attribute $attribute */
721
            $attribute = $result[0];
722
723
            return $attribute->getArticle();
724
        }
725
726
        return null;
727
    }
728
729
    /**