Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Seblegall\ApiValidatorBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
9
/**
10
 * This is the class that validates and merges configuration from your app/config files.
11
 *
12
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
13
 */
14
class Configuration implements ConfigurationInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19 4
    public function getConfigTreeBuilder()
20
    {
21 4
        $treeBuilder = new TreeBuilder();
22 4
        $rootNode = $treeBuilder->root('api_validator');
23
24 4
        $this->addContentTypeListenerSection($rootNode);
25
26 4
        return $treeBuilder;
27
    }
28
29 4
    private function addContentTypeListenerSection(ArrayNodeDefinition $rootNode)
30
    {
31
        $rootNode
32 4
            ->children()
33 4
                ->arrayNode('content_type_listener')
34 4
                    ->fixXmlConfig('decoder', 'decoders')
35 4
                    ->addDefaultsIfNotSet()
36 4
                    ->children()
37 4
                        ->arrayNode('decoders')
38 4
                            ->defaultValue(array('json' => 'api_validator.decoder.json'))
39 4
                            ->prototype('scalar')->end()
40 4
                        ->end()
41 4
                    ->end()
42 4
                ->end()
43 4
            ->end();
44 4
    }
45
}
46