<commit_before><?php

namespace PlentyConnector\Connector\ConfigService;

use Exception;
use PlentyConnector\Connector\ConfigService\Model\Config as ConfigModel;
use Shopware\Components\Model\ModelManager;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * TODO: Refactor
 * TODO: add readonly flag for container based config values (+ backend)
 *
 * Class ConfigService.
 */
class ConfigService implements ConfigServiceInterface
{
    /**
     * @var ModelManager
     */
    private $entityManager;

    /**
     * @var ModelManager
     */
    private $repository;

    /**
     * @var ContainerInterface
     */
    private $container;

    /**
     * Config data array.
     *
     * @var ConfigModel[]
     */
    private $config = [];

    /**
     * @param ModelManager $entityManager
     * @param ContainerInterface $container
     */
    public function __construct(ModelManager $entityManager, ContainerInterface $container)
    {
        $this->entityManager = $entityManager;
        $this->repository = $entityManager->getRepository(ConfigModel::class);
        $this->container = $container;

        $this->initialize();
    }

    /**
     * {@inheritdoc}
     */
    public function get($key, $default = null)
    {
        if ($this->container->hasParameter('shopware.plenty_connector.' . $key)) {
            try {
                return $this->container->getParameter('shopware.plenty_connector.' . $key);
            } catch (Exception $exception) {
                // fail silently
            }
        }

        if ($this->container->hasParameter('plenty_connector.config.' . $key)) {
            try {
                return $this->container->getParameter('plenty_connector.' . $key);
            } catch (Exception $exception) {
                // fail silently
            }
        }

        if (!array_key_exists($key, $this->config)) {
            return $default;
        }

        return $this->config[$key]->getValue();
    }
<commit_msg>cleaned the config service<commit_after><?php

namespace PlentyConnector\Connector\ConfigService;

use Exception;
use PlentyConnector\Connector\ConfigService\Model\Config as ConfigModel;
use Shopware\Components\Model\ModelManager;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * TODO: Refactor
 * TODO: add readonly flag for container based config values (+ backend)
 *
 * Class ConfigService.
 */
class ConfigService implements ConfigServiceInterface
{
    /**
     * @var ModelManager
     */
    private $entityManager;

    /**
     * @var ModelManager
     */
    private $repository;

    /**
     * @var ContainerInterface
     */
    private $container;

    /**
     * Config data array.
     *
     * @var ConfigModel[]
     */
    private $config = [];

    /**
     * @param ModelManager $entityManager
     * @param ContainerInterface $container
     */
    public function __construct(ModelManager $entityManager, ContainerInterface $container)
    {
        $this->entityManager = $entityManager;
        $this->repository = $entityManager->getRepository(ConfigModel::class);
        $this->container = $container;

        $this->initialize();
    }

    /**
     * {@inheritdoc}
     */
    public function get($key, $default = null)
    {
        if ($this->container->hasParameter('shopware.plenty_connector.' . $key)) {
            try {
                return $this->container->getParameter('shopware.plenty_connector.' . $key);
            } catch (Exception $exception) {
                // fail silently
            }
        }

        if (!array_key_exists($key, $this->config)) {
            return $default;
        }

        return $this->config[$key]->getValue();
    }

{'fraction_non_alphanumeric': 0.12452931683700914, 'fraction_numerical': 0.0, 'mean_word_length': 2.323503127792672, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2480749', 'n_tokens_mistral': 984, 'n_tokens_neox': 970, 'n_words': 203}