Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 54
ccs 0
cts 44
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 48 1
1
<?php
2
3
namespace Nicofuma\SwaggerBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * This class contains the configuration information for the bundle.
10
 *
11
 * This information is solely responsible for how the different configuration
12
 * sections are normalized, and merged.
13
 */
14
class Configuration implements ConfigurationInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function getConfigTreeBuilder()
20
    {
21
        $treeBuilder = new TreeBuilder();
22
        $rootNode = $treeBuilder->root('nicofuma_swagger', 'array');
23
24
        $rootNode
25
            ->fixXmlConfig('definition')
26
            ->children()
27
                ->arrayNode('definitions')
28
                    ->prototype('array')
29
                        ->children()
30
                            ->arrayNode('pattern')
31
                                ->beforeNormalization()->ifString()->then(function ($v) {
32
                                    return ['path' => $v];
33
                                })->end()
34
                                ->fixXmlConfig('ip')
35
                                ->fixXmlConfig('method')
36
                                ->children()
37
                                    ->scalarNode('path')
38
                                        ->defaultNull()
39
                                        ->info('use the urldecoded format')
40
                                     ->example('^/path to resource/')
41
                                    ->end()
42
                                    ->scalarNode('host')->defaultNull()->end()
43
                                    ->arrayNode('ips')
44
                                        ->beforeNormalization()->ifString()->then(function ($v) {
45
                                            return [$v];
46
                                        })->end()
47
                                        ->prototype('scalar')->end()
48
                                    ->end()
49
                                    ->arrayNode('methods')
50
                                        ->beforeNormalization()->ifString()->then(function ($v) {
51
                                            return preg_split('/\s*,\s*/', $v);
52
                                        })->end()
53
                                        ->prototype('scalar')->end()
54
                                    ->end()
55
                                ->end()
56
                            ->end()
57
                            ->scalarNode('swagger_file')->end()
58
                            ->booleanNode('strict')->defaultTrue()->end()
59
                        ->end()
60
                    ->end()
61
                ->end()
62
            ->end()
63
        ;
64
65
        return $treeBuilder;
66
    }
67
}
68