Code Duplication    Length = 7-8 lines in 2 locations

Components/Helper.php 2 locations

@@ 842-848 (lines=7) @@
839
                        'SELECT `id` FROM s_plugin_connect_categories WHERE category_key = ? AND shop_id = ?',
840
                        [$categoryKey, $shopId]
841
                    );
842
                    if (!($res = $selectedCategory->fetch())) {
843
                        $this->manager->getConnection()->executeQuery(
844
                            'INSERT INTO s_plugin_connect_categories (category_key, label, shop_id) VALUES (?, ?, ?)',
845
                            [$categoryKey, $category, $shopId]
846
                        );
847
                        $categoryId = (int) $this->manager->getConnection()->lastInsertId();
848
                    } else {
849
                        $categoryId = (int) $res['id'];
850
                    }
851
                    $selectedProductToCategory = $this->manager->getConnection()->executeQuery(
@@ 952-959 (lines=8) @@
949
            'SELECT `id` FROM s_plugin_connect_categories WHERE category_key = ? AND shop_id IS NULL',
950
            [$categoryKey]
951
        );
952
        if (!($res = $selectedCategory->fetch())) {
953
            $this->manager->getConnection()->executeQuery(
954
                'INSERT INTO s_plugin_connect_categories (category_key, label, shop_id) VALUES (?, ?, ?)',
955
                [$categoryKey, $category, $shopId]
956
            );
957
            $createdCategoryId = (int) $this->manager->getConnection()->lastInsertId();
958
            $this->assignLocalCategories($createdCategoryId, $categoryKey);
959
960
            return $createdCategoryId;
961
        }
962