<commit_before><?php

/*
 * This file is part of the Elcodi package.
 *
 * Copyright (c) 2014 Elcodi.com
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * Feel free to edit as you please, and have fun.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */

namespace Elcodi\Bundle\CurrencyBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

use Elcodi\Bundle\CoreBundle\DependencyInjection\Abstracts\AbstractConfiguration;
use Elcodi\Component\Currency\Adapter\CurrencyExchangeRatesProvider\DummyProviderAdapter as DummyCurrencyExchangeRatesProviderAdapter;
use Elcodi\Component\Currency\Adapter\CurrencyExchangeRatesProvider\OpenExchangeRatesProviderAdapter;
use Elcodi\Component\Currency\Adapter\LocaleProvider\DummyProviderAdapter as DummyLocaleProviderAdapter;
use Elcodi\Component\Currency\Adapter\LocaleProvider\ElcodiProviderAdapter;

/**
 * This is the class that validates and merges configuration from your app/config files
 */
class Configuration extends AbstractConfiguration implements ConfigurationInterface
{
    /**
     * {@inheritDoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root($this->extensionName);

        $rootNode
            ->children()
                ->arrayNode('mapping')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->append($this->addMappingNode(
                            'currency',
                            'Elcodi\Component\Currency\Entity\Currency',
                            '@ElcodiCurrencyBundle/Resources/config/doctrine/Currency.orm.yml',
                            'default',
                            true
                        ))
                        ->append($this->addMappingNode(
                            'currency_exchange_rate',
                            'Elcodi\Component\Currency\Entity\CurrencyExchangeRate',
                            '@ElcodiCurrencyBundle/Resources/config/doctrine/CurrencyExchangeRate.orm.yml',
                            'default',
                            true
                        ))
                    ->end()
                ->end()
                ->arrayNode('currency')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('default_currency')
                            ->defaultValue('USD')
                        ->end()
                        ->scalarNode('session_field_name')
                            ->defaultValue('currency_id')
                        ->end()
                    ->end()
                ->end()
                ->arrayNode('rates_provider')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('currency_base')
                            ->defaultValue('USD')
                        ->end()
                        ->enumNode('client')
                            ->values([
                                DummyCurrencyExchangeRatesProviderAdapter::ADAPTER_NAME,
                                OpenExchangeRatesProviderAdapter::ADAPTER_NAME
                            ])
                            ->defaultValue(DummyCurrencyExchangeRatesProviderAdapter::ADAPTER_NAME)
                        ->end()
                    ->end()
                    ->append($this->addOpenExchangeRatesParametersNode())
                ->end()
                ->arrayNode('locale_provider')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->enumNode('adapter')
                            ->values([
                                DummyLocaleProviderAdapter::ADAPTER_NAME,
                                ElcodiProviderAdapter::ADAPTER_NAME
                            ])
                            ->defaultValue(DummyLocaleProviderAdapter::ADAPTER_NAME)
                        ->end()
                    ->end()
                ->end()
            ->end();

        return $treeBuilder;
    }

    /**
     * Require Open exchange configuration
     */
    public function addOpenExchangeRatesParametersNode()<commit_msg>extract `getConfigTreeBuilder`<commit_after><?php

/*
 * This file is part of the Elcodi package.
 *
 * Copyright (c) 2014 Elcodi.com
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * Feel free to edit as you please, and have fun.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */

namespace Elcodi\Bundle\CurrencyBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;

use Elcodi\Bundle\CoreBundle\DependencyInjection\Abstracts\AbstractConfiguration;
use Elcodi\Component\Currency\Adapter\CurrencyExchangeRatesProvider\DummyProviderAdapter as DummyCurrencyExchangeRatesProviderAdapter;
use Elcodi\Component\Currency\Adapter\CurrencyExchangeRatesProvider\OpenExchangeRatesProviderAdapter;
use Elcodi\Component\Currency\Adapter\LocaleProvider\DummyProviderAdapter as DummyLocaleProviderAdapter;
use Elcodi\Component\Currency\Adapter\LocaleProvider\ElcodiProviderAdapter;

/**
 * Class Configuration
 */
class Configuration extends AbstractConfiguration
{
    /**
     * {@inheritDoc}
     */
    protected function setupTree(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->children()
                ->arrayNode('mapping')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->append($this->addMappingNode(
                            'currency',
                            'Elcodi\Component\Currency\Entity\Currency',
                            '@ElcodiCurrencyBundle/Resources/config/doctrine/Currency.orm.yml',
                            'default',
                            true
                        ))
                        ->append($this->addMappingNode(
                            'currency_exchange_rate',
                            'Elcodi\Component\Currency\Entity\CurrencyExchangeRate',
                            '@ElcodiCurrencyBundle/Resources/config/doctrine/CurrencyExchangeRate.orm.yml',
                            'default',
                            true
                        ))
                    ->end()
                ->end()
                ->arrayNode('currency')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('default_currency')
                            ->defaultValue('USD')
                        ->end()
                        ->scalarNode('session_field_name')
                            ->defaultValue('currency_id')
                        ->end()
                    ->end()
                ->end()
                ->arrayNode('rates_provider')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('currency_base')
                            ->defaultValue('USD')
                        ->end()
                        ->enumNode('client')
                            ->values([
                                DummyCurrencyExchangeRatesProviderAdapter::ADAPTER_NAME,
                                OpenExchangeRatesProviderAdapter::ADAPTER_NAME
                            ])
                            ->defaultValue(DummyCurrencyExchangeRatesProviderAdapter::ADAPTER_NAME)
                        ->end()
                    ->end()
                    ->append($this->addOpenExchangeRatesParametersNode())
                ->end()
                ->arrayNode('locale_provider')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->enumNode('adapter')
                            ->values([
                                DummyLocaleProviderAdapter::ADAPTER_NAME,
                                ElcodiProviderAdapter::ADAPTER_NAME
                            ])
                            ->defaultValue(DummyLocaleProviderAdapter::ADAPTER_NAME)
                        ->end()
                    ->end()
                ->end()
            ->end();
    }

    /**
     * Require Open exchange configuration
     */
    public function addOpenExchangeRatesParametersNode()
{'fraction_non_alphanumeric': 0.09317784256559766, 'fraction_numerical': 0.0009329446064139942, 'mean_word_length': 1.3935249790678204, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 107, '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': '7232484', 'n_tokens_mistral': 1957, 'n_tokens_neox': 1868, 'n_words': 305}