<commit_before><?php
/**
 * AnimeDb package.
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2014, <NAME>
 * @license   http://opensource.org/licenses/MIT
 */
namespace AnimeDb\Bundle\CacheTimeKeeperBundle\DependencyInjection;

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

class Configuration implements ConfigurationInterface
{
    /**
     * @var string
     */
    protected $shmop_salt = '';

    /**
     * @var string
     */
    protected $file_path = '';

    /**
     * @param string $shmop_salt
     * @param string $file_path
     */
    public function __construct($shmop_salt, $file_path)
    {
        $this->shmop_salt = $shmop_salt;
        $this->file_path = $file_path;
    }

    /**
     * @return TreeBuilder
     */
    public function getConfigTreeBuilder()
    {
        $tree_builder = new TreeBuilder();
        $root_node = $tree_builder->root('anime_db_cache_time_keeper');

        /*
         * Example config:
         *
         * anime_db_cache_time_keeper:
         *     use_driver: file
         *     drivers:
         *         multi:
         *             fast: shmop
         *             slow: file
         *         shmop:
         *             salt: '%secret%'
         *         file:
         *             path: '%kernel.root_dir%/cache/cache-time-keeper/'
         *         memcached:
         *             prefix: 'cache_time_keeper_'
         *             persistent_id: 'cache_time_keeper'
         *             hosts:
         *                 - {host: 'localhost', port: 11211, weight: 100}
         */
        $root_node
            ->children()
                ->scalarNode('use_driver')
                    ->cannotBeEmpty()
                    ->defaultValue('file')
                ->end()
                ->arrayNode('drivers')
                    ->append($this->getDriverFile())
                    ->append($this->getDriverMemcached())
                    ->append($this->getDriverMulti())
                    ->append($this->getDriverShmop())
                ->end()
            ->end();

        return $tree_builder;
    }

    /**
     * @return ArrayNodeDefinition
     */
    protected function getDriverMulti()
    {
        $tree_builder = new TreeBuilder();

        return $tree_builder
            ->root('multi')
                ->children()
                    ->scalarNode('fast')
                        ->cannotBeEmpty()
                        ->defaultValue('shmop')
                    ->end()
                    ->scalarNode('slow')
                        ->cannotBeEmpty()
                        ->defaultValue('file')
                    ->end()
                ->end();
    }

    /**
     * @return ArrayNodeDefinition
     */
    protected function getDriverShmop()
    {
        $tree_builder = new TreeBuilder();

        return $tree_builder
            ->root('shmop')
                ->children()
                    ->scalarNode('salt')
                        ->cannotBeEmpty()
                        ->defaultValue($this->shmop_salt)
                    ->end()
                ->end();
    }

    /**
     * @return ArrayNodeDefinition
     */
    protected function getDriverFile()
    {
        $tree_builder = new TreeBuilder();

        return $tree_builder
            ->root('file')
                ->children()
                    ->scalarNode('path')
                        ->cannotBeEmpty()
                        ->defaultValue($this->file_path)
                    ->end()
                ->end();
    }

    /**
     * @return ArrayNodeDefinition
     */
    protected function getDriverMemcached()
    {
        $tree_builder = new TreeBuilder();

        return $tree_builder
            ->root('memcached')
                ->children()
                    ->scalarNode('prefix')
                        ->defaultValue('cache_time_keeper_')
                    ->end()
                    ->scalarNode('persistent_id')
                        ->defaultValue('cache_time_keeper')
                        ->info(
                            'Specify to enable persistent connections. '.
                            'All clients with the same ID share connections.'
                        )
                    ->end()
                    ->arrayNode('hosts')
                        ->requiresAtLeastOneElement()
                        ->prototype('array')
                            ->children()
                                ->scalarNode('host')
                                    ->cannotBeEmpty()
                                    ->defaultValue('localhost')
                                ->end()
                                ->scalarNode('port')
                                    ->cannotBeEmpty()
                                    ->defaultValue(11211)
                                    ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_numeric($v);
                                    })
                                        ->thenInvalid('Host port must be numeric')
                                    ->end()
                                ->end()
                                ->scalarNode('weight')
                                    ->defaultValue(0)
                                    ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_numeric($v);
                                    })
                                        ->thenInvalid('Host weight must be numeric')
                                    ->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end();
    }
}
<commit_msg>move out comments<commit_after><?php
/**
 * AnimeDb package.
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2014, <NAME>
 * @license   http://opensource.org/licenses/MIT
 */
namespace AnimeDb\Bundle\CacheTimeKeeperBundle\DependencyInjection;

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

class Configuration implements ConfigurationInterface
{
    /**
     * @var string
     */
    protected $shmop_salt = '';

    /**
     * @var string
     */
    protected $file_path = '';

    /**
     * @param string $shmop_salt
     * @param string $file_path
     */
    public function __construct($shmop_salt, $file_path)
    {
        $this->shmop_salt = $shmop_salt;
        $this->file_path = $file_path;
    }

    /**
     * Config tree builder.
     *
     * Example config:
     *
     * anime_db_cache_time_keeper:
     *     use_driver: file
     *     drivers:
     *         multi:
     *             fast: shmop
     *             slow: file
     *         shmop:
     *             salt: '%secret%'
     *         file:
     *             path: '%kernel.root_dir%/cache/cache-time-keeper/'
     *         memcached:
     *             prefix: 'cache_time_keeper_'
     *             persistent_id: 'cache_time_keeper'
     *             hosts:
     *                 - {host: 'localhost', port: 11211, weight: 100}
     *
     * @return TreeBuilder
     */
    public function getConfigTreeBuilder()
    {
        $tree_builder = new TreeBuilder();
        $tree_builder
            ->root('anime_db_cache_time_keeper')
                ->children()
                    ->scalarNode('use_driver')
                        ->cannotBeEmpty()
                        ->defaultValue('file')
                    ->end()
                    ->arrayNode('drivers')
                        ->append($this->getDriverFile())
                        ->append($this->getDriverMemcached())
                        ->append($this->getDriverMulti())
                        ->append($this->getDriverShmop())
                    ->end()
                ->end();

        return $tree_builder;
    }

    /**
     * @return ArrayNodeDefinition
     */
    protected function getDriverMulti()
    {
        $tree_builder = new TreeBuilder();

        return $tree_builder
            ->root('multi')
                ->children()
                    ->scalarNode('fast')
                        ->cannotBeEmpty()
                        ->defaultValue('shmop')
                    ->end()
                    ->scalarNode('slow')
                        ->cannotBeEmpty()
                        ->defaultValue('file')
                    ->end()
                ->end();
    }

    /**
     * @return ArrayNodeDefinition
     */
    protected function getDriverShmop()
    {
        $tree_builder = new TreeBuilder();

        return $tree_builder
            ->root('shmop')
                ->children()
                    ->scalarNode('salt')
                        ->cannotBeEmpty()
                        ->defaultValue($this->shmop_salt)
                    ->end()
                ->end();
    }

    /**
     * @return ArrayNodeDefinition
     */
    protected function getDriverFile()
    {
        $tree_builder = new TreeBuilder();

        return $tree_builder
            ->root('file')
                ->children()
                    ->scalarNode('path')
                        ->cannotBeEmpty()
                        ->defaultValue($this->file_path)
                    ->end()
                ->end();
    }

    /**
     * @return ArrayNodeDefinition
     */
    protected function getDriverMemcached()
    {
        $tree_builder = new TreeBuilder();

        return $tree_builder
            ->root('memcached')
                ->children()
                    ->scalarNode('prefix')
                        ->defaultValue('cache_time_keeper_')
                    ->end()
                    ->scalarNode('persistent_id')
                        ->defaultValue('cache_time_keeper')
                        ->info(
                            'Specify to enable persistent connections. '.
                            'All clients with the same ID share connections.'
                        )
                    ->end()
                    ->arrayNode('hosts')
                        ->requiresAtLeastOneElement()
                        ->prototype('array')
                            ->children()
                                ->scalarNode('host')
                                    ->cannotBeEmpty()
                                    ->defaultValue('localhost')
                                ->end()
                                ->scalarNode('port')
                                    ->cannotBeEmpty()
                                    ->defaultValue(11211)
                                    ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_numeric($v);
                                    })
                                        ->thenInvalid('Host port must be numeric')
                                    ->end()
                                ->end()
                                ->scalarNode('weight')
                                    ->defaultValue(0)
                                    ->validate()
                                    ->ifTrue(function ($v) {
                                        return !is_numeric($v);
                                    })
                                        ->thenInvalid('Host weight must be numeric')
                                    ->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end();
    }
}

{'fraction_non_alphanumeric': 0.1126571668063705, 'fraction_numerical': 0.0030176026823134955, 'mean_word_length': 0.9613677461778728, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 175, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3388049', 'n_tokens_mistral': 2872, 'n_tokens_neox': 2648, 'n_words': 462}