<commit_before><?php

/*
 * This file is part of the Tolerance package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Tolerance\Bridge\Symfony\Bundle\ToleranceBundle\DependencyInjection;

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

class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritdoc}
     */
    public function getConfigTreeBuilder()
    {
        $builder = new TreeBuilder();

        $root = $builder->root('tolerance');

        $root
            ->children()
            ->append($this->getOperationRunnersNode())
            ->append($this->getMetricsNode())
            ->booleanNode('operation_runner_listener')->defaultTrue()->end()
            ->append($this->getAopNode())
            ->append($this->getTracerNode())
            ->end();

        return $builder;
    }

    private function getOperationRunnersNode()
    {
        $builder = new TreeBuilder();
        $node = $builder->root('operation_runners');

        $children = $node
            ->useAttributeAsKey('name')
            ->prototype('array')
            ->children();

        foreach ($this->getOperationRunnerNodes() as $runnerNode) {
            $children->append($runnerNode);
        }

        $children
            ->end()
            ->end();

        return $node;
    }

    private function getOperationRunnerNodes(array $except = [])
    {
        $builder = new TreeBuilder();
        $nodes = [];

        if (!in_array('retry', $except)) {
            $retryNode = $builder->root('retry');
            $children = $retryNode
                ->children()
                    ->arrayNode('waiter')
                    ->isRequired()
                        ->children();

            foreach ($this->getWaiterNodes() as $node) {
                $children->append($node);
            }

            $runnerChildren = $retryNode
                ->children()
                    ->arrayNode('runner')
                        ->children();

            foreach ($this->getOperationRunnerNodes($except + ['retry']) as $runner) {
                $runnerChildren->append($runner);
            }

            $nodes[] = $retryNode;
        }

        if (!in_array('callback', $except)) {
            $retryNode = $builder->root('callback');

            $nodes[] = $retryNode;
        }

        if (!in_array('success_failure_metrics', $except)) {
            $successFailureMetricsNode = $builder->root('success_failure_metrics');

            $successFailureMetricsNode
                ->children()
                    ->scalarNode('runner')->defaultValue('tolerance.operation_runners.default')->end()
                    ->scalarNode('publisher')->isRequired()->end()
                    ->scalarNode('namespace')->isRequired()->end()
                ->end()
            ;

            $nodes[] = $successFailureMetricsNode;
        }

        if (!in_array('buffered', $except)) {
            $bufferedNode = $builder->root('buffered');

            $bufferedNode
                ->children()
                    ->scalarNode('runner')->defaultValue('tolerance.operation_runners.default')->end()
                    ->scalarNode('buffer')->defaultValue('in_memory')->end()
                ->end()
            ;

            $nodes[] = $bufferedNode;
        }

        if (!in_array('placeholder', $except)) {
            $placeholderNode = $builder->root('placeholder');

            $placeholderNode
                ->children()
                    ->scalarNode('runner')->defaultValue('tolerance.operation_runners.default')->end()
                    ->scalarNode('value')->defaultNull()->end()
                    ->scalarNode('logger')->defaultNull()->end()
                ->end()
            ;

            $nodes[] = $placeholderNode;
        }
<commit_msg>Allow any variable type in placeholder's value<commit_after><?php

/*
 * This file is part of the Tolerance package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Tolerance\Bridge\Symfony\Bundle\ToleranceBundle\DependencyInjection;

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

class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritdoc}
     */
    public function getConfigTreeBuilder()
    {
        $builder = new TreeBuilder();

        $root = $builder->root('tolerance');

        $root
            ->children()
            ->append($this->getOperationRunnersNode())
            ->append($this->getMetricsNode())
            ->booleanNode('operation_runner_listener')->defaultTrue()->end()
            ->append($this->getAopNode())
            ->append($this->getTracerNode())
            ->end();

        return $builder;
    }

    private function getOperationRunnersNode()
    {
        $builder = new TreeBuilder();
        $node = $builder->root('operation_runners');

        $children = $node
            ->useAttributeAsKey('name')
            ->prototype('array')
            ->children();

        foreach ($this->getOperationRunnerNodes() as $runnerNode) {
            $children->append($runnerNode);
        }

        $children
            ->end()
            ->end();

        return $node;
    }

    private function getOperationRunnerNodes(array $except = [])
    {
        $builder = new TreeBuilder();
        $nodes = [];

        if (!in_array('retry', $except)) {
            $retryNode = $builder->root('retry');
            $children = $retryNode
                ->children()
                    ->arrayNode('waiter')
                    ->isRequired()
                        ->children();

            foreach ($this->getWaiterNodes() as $node) {
                $children->append($node);
            }

            $runnerChildren = $retryNode
                ->children()
                    ->arrayNode('runner')
                        ->children();

            foreach ($this->getOperationRunnerNodes($except + ['retry']) as $runner) {
                $runnerChildren->append($runner);
            }

            $nodes[] = $retryNode;
        }

        if (!in_array('callback', $except)) {
            $retryNode = $builder->root('callback');

            $nodes[] = $retryNode;
        }

        if (!in_array('success_failure_metrics', $except)) {
            $successFailureMetricsNode = $builder->root('success_failure_metrics');

            $successFailureMetricsNode
                ->children()
                    ->scalarNode('runner')->defaultValue('tolerance.operation_runners.default')->end()
                    ->scalarNode('publisher')->isRequired()->end()
                    ->scalarNode('namespace')->isRequired()->end()
                ->end()
            ;

            $nodes[] = $successFailureMetricsNode;
        }

        if (!in_array('buffered', $except)) {
            $bufferedNode = $builder->root('buffered');

            $bufferedNode
                ->children()
                    ->scalarNode('runner')->defaultValue('tolerance.operation_runners.default')->end()
                    ->scalarNode('buffer')->defaultValue('in_memory')->end()
                ->end()
            ;

            $nodes[] = $bufferedNode;
        }

        if (!in_array('placeholder', $except)) {
            $placeholderNode = $builder->root('placeholder');

            $placeholderNode
                ->children()
                    ->scalarNode('runner')->defaultValue('tolerance.operation_runners.default')->end()
                    ->variableNode('value')->defaultNull()->end()
                    ->scalarNode('logger')->defaultNull()->end()
                ->end()
            ;

            $nodes[] = $placeholderNode;
        }

{'fraction_non_alphanumeric': 0.14687227956721802, 'fraction_numerical': 0.0, 'mean_word_length': 1.8011145942180424, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 145, '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': '7325437', 'n_tokens_mistral': 2021, 'n_tokens_neox': 1917, 'n_words': 336}