<commit_before><?php

namespace TreeHouse\CacheBundle\DependencyInjection\Configuration;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use TreeHouse\Cache\CacheInterface;

class Configuration implements ConfigurationInterface
{
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode    = $treeBuilder->root('treehouse_cache');

        $this->addClientsSection($rootNode);

        return $treeBuilder;
    }

    /**
     * Adds the treehouse_cache.clients configuration
     *
     * @param ArrayNodeDefinition $rootNode
     */
    private function addClientsSection(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->fixXmlConfig('client')
            ->children()
                ->arrayNode('clients')
                    ->isRequired()
                    ->requiresAtLeastOneElement()
                    ->useAttributeAsKey('name', false)
                    ->prototype('array')
                        ->children()
                            ->enumNode('type')
                                ->isRequired()
                                ->values(['phpredis', 'memcached'])
                                ->info('The type of cache')
                            ->end()

                            ->scalarNode('dsn')
                                ->isRequired()
                                ->info(
                                    'DSN of the cache, prefix this with the protocol, ' .
                                    'ie: redis:///var/run/redis.sock or memcached://localhost:11211'
                                )
                            ->end()

                            ->arrayNode('connection')
                                ->addDefaultsIfNotSet()
                                ->children()
                                    ->booleanNode('persistent')
                                        ->defaultTrue()
                                        ->info('Whether to use a persistent connection. Only available for redis cache')
                                    ->end()
                                    ->scalarNode('timeout')
                                        ->defaultValue(5)
                                        ->info('Timeout to use when connecting')
                                    ->end()
                                ->end()
                            ->end()

                            ->scalarNode('prefix')
                                ->defaultNull()
                                ->info('Prefix to use for the cached keys')
                            ->end()

                            ->enumNode('serializer')
                                ->defaultValue(CacheInterface::SERIALIZE_AUTO)
                                ->values([
                                    CacheInterface::SERIALIZE_AUTO,
                                    CacheInterface::SERIALIZE_IGBINARY,
                                    CacheInterface::SERIALIZE_JSON,
                                    CacheInterface::SERIALIZE_PHP,
                                ])
                            ->end()

                            ->scalarNode('serializer_class')
                            ->end()

                            ->booleanNode('in_memory')
                                ->defaultTrue()
                                ->info('Whether to wrap the cache in an in-memory caching decorator')
                            ->end()
                        ->end()
                    ->end()
                ->end()

                ->arrayNode('orm')
                    ->children()
                        ->scalarNode('client')
                            ->info('The cache client you want to use for the ORM cache')
                        ->end()
                    ->end()<commit_msg>Fixed serializer configuration values<commit_after><?php

namespace TreeHouse\CacheBundle\DependencyInjection\Configuration;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use TreeHouse\Cache\CacheInterface;

class Configuration implements ConfigurationInterface
{
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode    = $treeBuilder->root('treehouse_cache');

        $this->addClientsSection($rootNode);

        return $treeBuilder;
    }

    /**
     * Adds the treehouse_cache.clients configuration
     *
     * @param ArrayNodeDefinition $rootNode
     */
    private function addClientsSection(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->fixXmlConfig('client')
            ->children()
                ->arrayNode('clients')
                    ->isRequired()
                    ->requiresAtLeastOneElement()
                    ->useAttributeAsKey('name', false)
                    ->prototype('array')
                        ->children()
                            ->enumNode('type')
                                ->isRequired()
                                ->values(['phpredis', 'memcached'])
                                ->info('The type of cache')
                            ->end()

                            ->scalarNode('dsn')
                                ->isRequired()
                                ->info(
                                    'DSN of the cache, prefix this with the protocol, ' .
                                    'ie: redis:///var/run/redis.sock or memcached://localhost:11211'
                                )
                            ->end()

                            ->arrayNode('connection')
                                ->addDefaultsIfNotSet()
                                ->children()
                                    ->booleanNode('persistent')
                                        ->defaultTrue()
                                        ->info('Whether to use a persistent connection. Only available for redis cache')
                                    ->end()
                                    ->scalarNode('timeout')
                                        ->defaultValue(5)
                                        ->info('Timeout to use when connecting')
                                    ->end()
                                ->end()
                            ->end()

                            ->scalarNode('prefix')
                                ->defaultNull()
                                ->info('Prefix to use for the cached keys')
                            ->end()

                            ->enumNode('serializer')
                                ->defaultValue('auto')
                                ->values([
                                    'auto',
                                    'igbinary',
                                    'json',
                                    'php',
                                ])
                            ->end()

                            ->scalarNode('serializer_class')
                            ->end()

                            ->booleanNode('in_memory')
                                ->defaultTrue()
                                ->info('Whether to wrap the cache in an in-memory caching decorator')
                            ->end()
                        ->end()
                    ->end()
                ->end()

                ->arrayNode('orm')
                    ->children()
                        ->scalarNode('client')
                            ->info('The cache client you want to use for the ORM cache')
                        ->end()
                    ->end()
{'fraction_non_alphanumeric': 0.09447821681864235, 'fraction_numerical': 0.001519756838905775, 'mean_word_length': 0.8660207939508506, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3838134', 'n_tokens_mistral': 1622, 'n_tokens_neox': 1502, 'n_words': 306}