Completed
Push — master ( 9c5fdf...27a5d2 )
by John
7s
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 62
Code Lines 56

Duplication

Lines 0
Ratio 0 %

Importance

Changes 11
Bugs 3 Features 0
Metric Value
c 11
b 3
f 0
dl 0
loc 62
rs 9.4743
cc 1
eloc 56
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
                ->arrayNode('errors')
30
                    ->addDefaultsIfNotSet()
31
                    ->children()
32
                        ->scalarNode('strategy')
33
                            ->defaultValue('simple')
34
                            ->cannotBeEmpty()
35
                            ->info('Strategy name or error response factory DI key')
36
                        ->end()
37
                        ->scalarNode('logref_builder')
38
                            ->defaultValue('uniqid')
39
                            ->cannotBeEmpty()
40
                            ->info('Strategy name or error response factory DI key')
41
                        ->end()
42
                    ->end()
43
                ->end()
44
45
                ->arrayNode('serializer')
46
                    ->addDefaultsIfNotSet()
47
                    ->children()
48
                        ->enumNode('type')
49
                            ->values(array('array', 'object', 'jms', 'symfony'))
50
                            ->defaultValue('array')
51
                            ->cannotBeEmpty()
52
                        ->end()
53
                        ->arrayNode('namespace')
54
                            ->beforeNormalization()
55
                                ->ifString()
56
                                ->then(function ($v) {
57
                                    return [$v];
58
                                })
59
                            ->end()
60
                            ->prototype('scalar')
61
                            ->end()
62
                        ->end()
63
                    ->end()
64
                ->end()
65
                ->arrayNode('document')
66
                    ->addDefaultsIfNotSet()
67
                    ->children()
68
                        ->scalarNode('cache')->isRequired()->defaultFalse()->end()
69
                        ->scalarNode('base_path')->defaultValue('')->end()
70
                        ->arrayNode('public')
71
                            ->addDefaultsIfNotSet()
72
                            ->children()
73
                                ->scalarNode('scheme')->defaultNull()->end()
74
                                ->scalarNode('base_url')->defaultValue('/')->end()
75
                                ->scalarNode('host')->defaultNull()->end()
76
                            ->end()
77
                         ->end()
78
                    ->end()
79
                ->end()
80
            ->end()
81
            ;
82
        return $treeBuilder;
83
    }
84
}
85