Configuration::getConfigTreeBuilder()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 82
Code Lines 78

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 77
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 82
ccs 77
cts 77
cp 1
rs 8.7769
cc 1
eloc 78
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 Innmind\Rest\Server\Action;
7
use Symfony\Component\Config\Definition\{
8
    Builder\TreeBuilder,
9
    Builder\NodeBuilder,
10
    ConfigurationInterface
11
};
12
13
final class Configuration implements ConfigurationInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 64
    public function getConfigTreeBuilder()
19
    {
20 64
        $treeBuilder = new TreeBuilder;
21 64
        $root = $treeBuilder->root('innmind_rest_server');
22
23
        $root
24 64
            ->children()
25 64
                ->arrayNode('types')
26 64
                    ->defaultValue([])
27 64
                    ->prototype('scalar')->end()
28 64
                ->end()
29 64
                ->arrayNode('accept')
30 64
                    ->info('The list of formats you accept in the "Accept" header')
31 64
                    ->useAttributeAsKey('name')
32 64
                    ->requiresAtLeastOneElement()
33 64
                    ->prototype('array')
34 64
                        ->children()
35 64
                            ->integerNode('priority')->end()
36 64
                            ->arrayNode('media_types')
37 64
                                ->useAttributeAsKey('name')
38 64
                                ->requiresAtLeastOneElement()
39 64
                                ->prototype('scalar')->end()
40 64
                            ->end()
41 64
                        ->end()
42 64
                    ->end()
43 64
                ->end()
44 64
                ->arrayNode('content_type')
45 64
                    ->info('The list of formats you support as content output')
46 64
                    ->useAttributeAsKey('name')
47 64
                    ->requiresAtLeastOneElement()
48 64
                    ->prototype('array')
49 64
                        ->children()
50 64
                            ->integerNode('priority')->end()
51 64
                            ->arrayNode('media_types')
52 64
                                ->useAttributeAsKey('name')
53 64
                                ->requiresAtLeastOneElement()
54 64
                                ->prototype('integer')->end()
55 64
                            ->end()
56 64
                        ->end()
57 64
                    ->end()
58 64
                ->end()
59 64
                ->scalarNode('specification_builder')
60 64
                    ->defaultValue('innmind_rest_server.specification_builder.default')
61 64
                ->end()
62 64
                ->scalarNode('range_extractor')
63 64
                    ->defaultValue('innmind_rest_server.range_extractor.delegation')
64 64
                ->end()
65 64
                ->arrayNode('response')
66 64
                    ->addDefaultsIfNotSet()
67 64
                    ->children()
68 64
                        ->arrayNode('header_builders')
69 64
                            ->addDefaultsIfNotSet()
70 64
                            ->children()
71 64
                                ->scalarNode((string) Action::list())
72 64
                                    ->defaultValue('innmind_rest_server.response.header_builder.list_delegation')
73 64
                                ->end()
74 64
                                ->scalarNode((string) Action::get())
75 64
                                    ->defaultValue('innmind_rest_server.response.header_builder.get_delegation')
76 64
                                ->end()
77 64
                                ->scalarNode((string) Action::create())
78 64
                                    ->defaultValue('innmind_rest_server.response.header_builder.create_delegation')
79 64
                                ->end()
80 64
                                ->scalarNode((string) Action::update())
81 64
                                    ->defaultValue('innmind_rest_server.response.header_builder.update_delegation')
82 64
                                ->end()
83 64
                                ->scalarNode((string) Action::remove())
84 64
                                    ->defaultValue('innmind_rest_server.response.header_builder.remove_delegation')
85 64
                                ->end()
86 64
                                ->scalarNode((string) Action::link())
87 64
                                    ->defaultValue('innmind_rest_server.response.header_builder.link_delegation')
88 64
                                ->end()
89 64
                                ->scalarNode((string) Action::unlink())
90 64
                                    ->defaultValue('innmind_rest_server.response.header_builder.unlink_delegation')
91 64
                                ->end()
92 64
                            ->end()
93 64
                        ->end()
94 64
                    ->end()
95 64
                ->end()
96 64
            ->end();
97
98 64
        return $treeBuilder;
99
    }
100
}
101