<commit_before><?php

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

namespace PMD\StateMachineBundle\DependencyInjection;

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

/**
 * Class Configuration
 * 
 * @author <NAME> <<EMAIL>>
 * @package PMD\StateMachineBundle\DependencyInjection
 */
class Configuration implements ConfigurationInterface
{
    /**
     * @inheritdoc
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = $this->createTreeBuilder();
        $rootNode = $treeBuilder->root('pmd_state_machine');

        $rootNode
            ->children()
                ->append($this->addRequestNode())
                ->append($this->addDefinitionsNode())
            ->end();

        return $treeBuilder;
    }

    /**
     * @return NodeDefinition
     */
    protected function addRequestNode()
    {
        $treeBuilder = $this->createTreeBuilder();
        $node = $treeBuilder->root('request');

        $node
            ->fixXmlConfig('attribute')
            ->addDefaultsIfNotSet()
            ->children()
                ->arrayNode('attribute')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('process_path')
                            ->isRequired()
                            ->cannotBeEmpty()
                            ->defaultValue('_state_process')
                        ->end()
                        ->scalarNode('action_path')
                            ->isRequired()
                            ->cannotBeEmpty()
                            ->defaultValue('_state_action')
                        ->end()
                    ->end()
                ->end()
            ->end();

        return $node;
    }

    /**
     * @return NodeDefinition
     */
    protected function addDefinitionsNode()
    {
        $treeBuilder = $this->createTreeBuilder();
        $node = $treeBuilder->root('definitions');

        $node
            ->fixXmlConfig('definition')
            ->performNoDeepMerging()
            ->useAttributeAsKey('name')
            ->prototype('array')
                ->cannotBeOverwritten()
                ->beforeNormalization()
                    ->always(
                        function (array $definition) {
                            return $this->normalizeDefinition($definition);
                        }
                    )<commit_msg>Fixed call configuration normalization<commit_after><?php

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

namespace PMD\StateMachineBundle\DependencyInjection;

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

/**
 * Class Configuration
 * 
 * @author <NAME> <<EMAIL>>
 * @package PMD\StateMachineBundle\DependencyInjection
 */
class Configuration implements ConfigurationInterface
{
    /**
     * @inheritdoc
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = $this->createTreeBuilder();
        $rootNode = $treeBuilder->root('pmd_state_machine');

        $rootNode
            ->children()
                ->append($this->addRequestNode())
                ->append($this->addDefinitionsNode())
            ->end();

        return $treeBuilder;
    }

    /**
     * @return NodeDefinition
     */
    protected function addRequestNode()
    {
        $treeBuilder = $this->createTreeBuilder();
        $node = $treeBuilder->root('request');

        $node
            ->fixXmlConfig('attribute')
            ->addDefaultsIfNotSet()
            ->children()
                ->arrayNode('attribute')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('process_path')
                            ->isRequired()
                            ->cannotBeEmpty()
                            ->defaultValue('_state_process')
                        ->end()
                        ->scalarNode('action_path')
                            ->isRequired()
                            ->cannotBeEmpty()
                            ->defaultValue('_state_action')
                        ->end()
                    ->end()
                ->end()
            ->end();

        return $node;
    }

    /**
     * @return NodeDefinition
     */
    protected function addDefinitionsNode()
    {
        $context = $this;
        $treeBuilder = $this->createTreeBuilder();
        $node = $treeBuilder->root('definitions');

        $node
            ->fixXmlConfig('definition')
            ->performNoDeepMerging()
            ->useAttributeAsKey('name')
            ->prototype('array')
                ->cannotBeOverwritten()
                ->beforeNormalization()
                    ->always(
                        function (array $definition) use ($context) {
                            return $context->normalizeDefinition($definition);
                        }
                    )
{'fraction_non_alphanumeric': 0.11755116826661836, 'fraction_numerical': 0.0, 'mean_word_length': 1.5695672405770125, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 93, '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': '4671572', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1264, 'n_words': 243}