Code Duplication    Length = 29-30 lines in 2 locations

Components/Config.php 2 locations

@@ 333-361 (lines=29) @@
330
     *
331
     * @param array $data
332
     */
333
    public function setImportConfigs($data)
334
    {
335
        foreach ($data as $config) {
336
            unset($config['id']);
337
            foreach ($config as $key => $configValue) {
338
                /** @var \Shopware\CustomModels\Connect\Config $model */
339
                $model = $this->getConfigRepository()->findOneBy([
340
                    'name' => $key,
341
                    'shopId' => null,
342
                    'groupName' => 'import'
343
                ]);
344
                if (is_null($model)) {
345
                    $model = new ConfigModel();
346
                    $model->setName($key);
347
                    $model->setGroupName('import');
348
                    $model->setShopId(null);
349
                }
350
351
                if (is_array($configValue)) {
352
                    $model->setValue(json_encode($configValue));
353
                } else {
354
                    $model->setValue($configValue);
355
                }
356
                $this->manager->persist($model);
357
            }
358
        }
359
360
        $this->manager->flush();
361
    }
362
363
    /**
364
     * Helper function which returns export configuration.
@@ 385-414 (lines=30) @@
382
        return $result;
383
    }
384
385
    public function setExportConfigs($data)
386
    {
387
        foreach ($data as $config) {
388
            unset($config['id']);
389
            foreach ($config as $key => $configValue) {
390
                /** @var \Shopware\CustomModels\Connect\Config $model */
391
                $model = $this->getConfigRepository()->findOneBy([
392
                    'name' => $key,
393
                    'shopId' => null,
394
                    'groupName' => 'export'
395
                ]);
396
                if (is_null($model)) {
397
                    $model = new ConfigModel();
398
                    $model->setName($key);
399
                    $model->setGroupName('export');
400
                    $model->setShopId(null);
401
                }
402
403
                if (is_array($configValue)) {
404
                    $model->setValue(json_encode($configValue));
405
                } else {
406
                    $model->setValue($configValue);
407
                }
408
409
                $this->manager->persist($model);
410
            }
411
        }
412
413
        $this->manager->flush();
414
    }
415
416
    /**
417
     * Stores units mapping