<commit_before><?php

namespace Oro\Bundle\EntityConfigBundle\Provider;

use Doctrine\ORM\PersistentCollection;

use Oro\Bundle\EntityConfigBundle\Config\Config;
use Oro\Bundle\EntityConfigBundle\Config\ConfigInterface;
use Oro\Bundle\EntityConfigBundle\Config\EntityConfig;
use Oro\Bundle\EntityConfigBundle\Config\FieldConfig;
use Oro\Bundle\EntityConfigBundle\Config\Id\EntityConfigId;
use Oro\Bundle\EntityConfigBundle\Config\Id\ConfigIdInterface;
use Oro\Bundle\EntityConfigBundle\Config\Id\FieldConfigId;
use Oro\Bundle\EntityConfigBundle\ConfigManager;

use Oro\Bundle\EntityConfigBundle\DependencyInjection\EntityConfigContainer;
use Oro\Bundle\EntityConfigBundle\Exception\RuntimeException;

class ConfigProvider implements ConfigProviderInterface
{
    /**
     * @var ConfigManager
     */
    protected $configManager;

    /**
     * @var EntityConfigContainer
     */
    protected $configContainer;

    /**
     * @var string
     */
    protected $scope;

    /**
     * @param ConfigManager         $configManager
     * @param EntityConfigContainer $configContainer
     */
    public function __construct(ConfigManager $configManager, EntityConfigContainer $configContainer)
    {
        $this->configManager   = $configManager;
        $this->configContainer = $configContainer;
        $this->scope           = $configContainer->getScope();
    }

    /**
     * @return EntityConfigContainer
     */
    public function getConfigContainer()
    {
        return $this->configContainer;
    }

    /**
     * @param $className
     * @return bool
     */
    public function isConfigurable($className)
    {
        return $this->configManager->isConfigurable($this->getClassName($className));
    }

    /**
     * @param $className
     * @return Config
     */
    public function getConfig($className)
    {
        return $this->configManager->getConfig(new EntityConfigId($this->getClassName($className), $this->scope));
    }

    /**
     * @param $className
     * @param $code
     * @return Config
     */
    public function getFieldConfig($className, $code)
    {
        $configId = new FieldConfigId($className, $this->scope, $code);
        return $this->getConfig($configId);
    }

    /**
     * @param $className
     * @param $code
     * @return Config
     */
    public function hasFieldConfig($className, $code)
    {
        return $this->isConfigurable($className)
            ? $this->getConfig($className)->hasField($code)
            : false;
    }

    /**
     * @param  ConfigIdInterface $configId
     * @param  array             $values
     * @return Config
     */
    public function createConfig(ConfigIdInterface $configId, array $values)
    {<commit_msg>refactoring configProvider<commit_after><?php

namespace Oro\Bundle\EntityConfigBundle\Provider;

use Doctrine\ORM\PersistentCollection;

use Oro\Bundle\EntityConfigBundle\Config\Config;
use Oro\Bundle\EntityConfigBundle\Config\ConfigInterface;
use Oro\Bundle\EntityConfigBundle\Config\Id\EntityConfigId;
use Oro\Bundle\EntityConfigBundle\Config\Id\ConfigIdInterface;
use Oro\Bundle\EntityConfigBundle\Config\Id\FieldConfigId;

use Oro\Bundle\EntityConfigBundle\ConfigManager;
use Oro\Bundle\EntityConfigBundle\DependencyInjection\EntityConfigContainer;
use Oro\Bundle\EntityConfigBundle\Exception\RuntimeException;

class ConfigProvider implements ConfigProviderInterface
{
    /**
     * @var ConfigManager
     */
    protected $configManager;

    /**
     * @var EntityConfigContainer
     */
    protected $configContainer;

    /**
     * @var string
     */
    protected $scope;

    /**
     * @param ConfigManager         $configManager
     * @param EntityConfigContainer $configContainer
     */
    public function __construct(ConfigManager $configManager, EntityConfigContainer $configContainer)
    {
        $this->configManager   = $configManager;
        $this->configContainer = $configContainer;
        $this->scope           = $configContainer->getScope();
    }

    /**
     * @return EntityConfigContainer
     */
    public function getConfigContainer()
    {
        return $this->configContainer;
    }

    /**
     * @param $className
     * @return bool
     */
    public function isConfigurable($className)
    {
        return $this->configManager->isConfigurable($this->getClassName($className));
    }

    /**
     * @param      $className
     * @param null $fieldName
     * @param null $fieldType
     * @return EntityConfigId|FieldConfigId
     */
    public function getConfigId($className, $fieldName = null, $fieldType = null)
    {
        if ($fieldName) {
            return new FieldConfigId($className, $this->getScope(), $fieldName, $fieldType);
        } else {
            return new EntityConfigId($className, $this->getScope());
        }
    }

    /**
     * @param      $className
     * @param null $fieldName
     * @return bool
     */
    public function hasConfig($className, $fieldName = null)
    {
        return $this->configManager->hasConfig($this->getConfigId($className, $fieldName));
    }

    /**
     * @param      $className
     * @param null $fieldName
     * @return null|Config|ConfigInterface
     */
    public function getConfig($className, $fieldName = null)
    {
        return $this->configManager->getConfig($this->getConfigId($className, $fieldName));
    }

    /**
     * @param  ConfigIdInterface $configId
     * @param  array             $values
     * @return Config
     */
    public function createConfig(ConfigIdInterface $configId, array $values)
    {
{'fraction_non_alphanumeric': 0.11290612098366541, 'fraction_numerical': 0.0, 'mean_word_length': 2.8829268292682926, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '6887776', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1508, 'n_words': 277}