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
@@ 717-741 (lines=25) @@
714
     * @param int $mode
715
     * @return null|ProductModel
716
     */
717
    public function getArticleByRemoteProduct(Product $product, $mode = Query::HYDRATE_OBJECT)
718
    {
719
        $builder = $this->manager->createQueryBuilder();
720
        $builder->select(['ba', 'd']);
721
        $builder->from('Shopware\CustomModels\Connect\Attribute', 'ba');
722
        $builder->join('ba.articleDetail', 'd');
723
        $builder->leftJoin('d.attribute', 'at');
724
725
        $builder->where('ba.groupId = :groupId AND ba.isMainVariant = 1 AND ba.shopId = :shopId');
726
        $query = $builder->getQuery();
727
728
        $query->setParameter('groupId', $product->groupId);
729
        $query->setParameter('shopId', $product->shopId);
730
        $result = $query->getResult(
731
            $mode
732
        );
733
734
        if (isset($result[0])) {
735
            /** @var \Shopware\CustomModels\Connect\Attribute $attribute */
736
            $attribute = $result[0];
737
738
            return $attribute->getArticle();
739
        }
740
741
        return null;
742
    }
743
744
    /**