Completed
Push — develop ( e716a3...960a7a )
by Baptiste
02:59
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 64
Code Lines 60

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 59
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 64
ccs 59
cts 59
cp 1
rs 9.3956
c 0
b 0
f 0
cc 1
eloc 60
nc 1
nop 0
crap 1

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
2
declare(strict_types = 1);
3
4
namespace Innmind\Rest\ServerBundle\DependencyInjection;
5
6
use Symfony\Component\Config\Definition\{
7
    Builder\TreeBuilder,
8
    Builder\NodeBuilder,
9
    ConfigurationInterface
10
};
11
12
final class Configuration implements ConfigurationInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 15
    public function getConfigTreeBuilder()
18
    {
19 15
        $treeBuilder = new TreeBuilder;
20 15
        $root = $treeBuilder->root('innmind_rest_server');
21
22
        $root
23 15
            ->children()
24 15
                ->arrayNode('types')
25 15
                    ->defaultValue([])
26 15
                    ->prototype('scalar')->end()
27 15
                ->end()
28 15
                ->arrayNode('accept')
29 15
                    ->info('The list of formats you accept in the "Accept" header')
30 15
                    ->useAttributeAsKey('name')
31 15
                    ->requiresAtLeastOneElement()
32 15
                    ->prototype('array')
33 15
                        ->children()
34 15
                            ->integerNode('priority')->end()
35 15
                            ->arrayNode('media_types')
36 15
                                ->useAttributeAsKey('name')
37 15
                                ->requiresAtLeastOneElement()
38 15
                                ->prototype('scalar')->end()
39 15
                            ->end()
40 15
                        ->end()
41 15
                    ->end()
42 15
                ->end()
43 15
                ->arrayNode('content_type')
44 15
                    ->info('The list of formats you support as content output')
45 15
                    ->useAttributeAsKey('name')
46 15
                    ->requiresAtLeastOneElement()
47 15
                    ->prototype('array')
48 15
                        ->children()
49 15
                            ->integerNode('priority')->end()
50 15
                            ->arrayNode('media_types')
51 15
                                ->useAttributeAsKey('name')
52 15
                                ->requiresAtLeastOneElement()
53 15
                                ->prototype('integer')->end()
54 15
                            ->end()
55 15
                        ->end()
56 15
                    ->end()
57 15
                ->end()
58 15
                ->scalarNode('specification_builder')
59 15
                    ->defaultValue('innmind_rest_server.specification_builder.default')
60 15
                ->end()
61 15
                ->scalarNode('range_extractor')
62 15
                    ->defaultValue('innmind_rest_server.range_extractor.delegation')
63 15
                ->end()
64 15
                ->arrayNode('response')
65 15
                    ->addDefaultsIfNotSet()
66 15
                    ->children()
67 15
                        ->arrayNode('header_builders')
68 15
                            ->addDefaultsIfNotSet()
69 15
                            ->children()
70 15
                                ->scalarNode('list')
71 15
                                    ->defaultValue('innmind_rest_server.response.header_builder.list_delegation')
72 15
                                ->end()
73 15
                            ->end()
74 15
                        ->end()
75 15
                    ->end()
76 15
                ->end()
77 15
            ->end();
78
79 15
        return $treeBuilder;
80
    }
81
}
82