Code Duplication    Length = 7-8 lines in 2 locations

Components/Helper.php 2 locations

@@ 842-848 (lines=7) @@
839
                foreach ($categories as $categoryKey => $category) {
840
                    $selectedCategory = $this->manager->getConnection()->executeQuery('SELECT `id` FROM s_plugin_connect_categories WHERE category_key = ? AND shop_id = ?',
841
                        [$categoryKey, $shopId]);
842
                    if (!($res = $selectedCategory->fetch())) {
843
                        $this->manager->getConnection()->executeQuery('INSERT INTO s_plugin_connect_categories (category_key, label, shop_id) VALUES (?, ?, ?)',
844
                            [$categoryKey, $category, $shopId]);
845
                        $categoryId = (int) $this->manager->getConnection()->lastInsertId();
846
                    } else {
847
                        $categoryId = (int) $res['id'];
848
                    }
849
                    $selectedProductToCategory = $this->manager->getConnection()->executeQuery('SELECT COUNT(*) FROM s_plugin_connect_product_to_categories WHERE connect_category_id = ? AND articleID = ?',
850
                        [$categoryId, (int) $row['article_id']]
851
                    )->fetchColumn();
@@ 941-948 (lines=8) @@
938
    {
939
        $selectedCategory = $this->manager->getConnection()->executeQuery('SELECT `id` FROM s_plugin_connect_categories WHERE category_key = ? AND shop_id IS NULL',
940
            [$categoryKey]);
941
        if (!($res = $selectedCategory->fetch())) {
942
            $this->manager->getConnection()->executeQuery('INSERT INTO s_plugin_connect_categories (category_key, label, shop_id) VALUES (?, ?, ?)',
943
                [$categoryKey, $category, $shopId]);
944
            $createdCategoryId = (int) $this->manager->getConnection()->lastInsertId();
945
            $this->assignLocalCategories($createdCategoryId, $categoryKey);
946
947
            return $createdCategoryId;
948
        }
949
950
        $this->manager->getConnection()->executeQuery('UPDATE s_plugin_connect_categories SET shop_id = ? WHERE id = ?',
951
            [$shopId, $res['id']]);