Completed
Push — master ( ad3b69...02c092 )
by John
09:08 queued 05:48
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 13
Bugs 3 Features 0
Metric Value
c 13
b 3
f 0
dl 0
loc 33
rs 8.8571
cc 1
eloc 28
nc 1
nop 0
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the KleijnWeb\SwaggerBundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\SwaggerBundle\DependencyInjection;
10
11
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
12
use Symfony\Component\Config\Definition\ConfigurationInterface;
13
14
/**
15
 * @author John Kleijn <[email protected]>
16
 */
17
class Configuration implements ConfigurationInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function getConfigTreeBuilder()
23
    {
24
        $treeBuilder = new TreeBuilder();
25
        $rootNode    = $treeBuilder->root('swagger');
26
27
        $rootNode
28
            ->children()
29
            ->scalarNode('validate_responses')->defaultFalse()
30
            ->end()
31
            ->arrayNode('hydrator')
32
            ->children()
33
            ->arrayNode('namespaces')->isRequired()
34
            ->beforeNormalization()
35
            ->ifString()
36
            ->then(function ($v) {
37
                return [$v];
38
            })
39
            ->end()
40
            ->prototype('scalar')
41
            ->end()
42
            ->end()
43
            ->end()
44
            ->end()
45
            ->arrayNode('document')
46
            ->addDefaultsIfNotSet()
47
            ->children()
48
            ->scalarNode('cache')->isRequired()->defaultFalse()->end()->scalarNode('base_path')->defaultValue('')->end()
49
            ->end()
50
            ->end()
51
            ->end();
52
53
        return $treeBuilder;
54
    }
55
}
56