Completed
Push — master ( 568e7c...33842a )
by Baptiste
02:25
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 51
Code Lines 47

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 46
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 51
ccs 46
cts 46
cp 1
rs 9.4109
cc 1
eloc 47
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\Neo4jBundle\DependencyInjection;
5
6
use Symfony\Component\Config\Definition\{
7
    Builder\TreeBuilder,
8
    Builder\NodeBuilder,
9
    ConfigurationInterface
10
};
11
12
class Configuration implements ConfigurationInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 44
    public function getConfigTreeBuilder()
18
    {
19 44
        $treeBuilder = new TreeBuilder;
20 44
        $root = $treeBuilder->root('innmind_neo4j');
21
22
        $root
23 44
            ->children()
24 44
                ->arrayNode('connection')
25 44
                    ->addDefaultsIfNotSet()
26 44
                    ->children()
27 44
                        ->scalarNode('host')
28 44
                            ->defaultValue('localhost')
29 44
                        ->end()
30 44
                        ->scalarNode('scheme')
31 44
                            ->defaultValue('https')
32 44
                        ->end()
33 44
                        ->integerNode('port')
34 44
                            ->defaultValue(7474)
35 44
                        ->end()
36 44
                        ->scalarNode('user')
37 44
                            ->defaultValue('neo4j')
38 44
                        ->end()
39 44
                        ->scalarNode('password')
40 44
                            ->defaultValue('neo4j')
41 44
                        ->end()
42 44
                        ->integerNode('timeout')
43 44
                            ->defaultValue(60)
44 44
                        ->end()
45 44
                    ->end()
46 44
                ->end()
47 44
                ->arrayNode('types')
48 44
                    ->defaultValue([])
49 44
                    ->prototype('scalar')->end()
50 44
                ->end()
51 44
                ->arrayNode('identity_generators')
52 44
                    ->info('Identity generators, with keys as identity classes and values as generator service name')
53 44
                    ->defaultValue([])
54 44
                    ->prototype('scalar')->end()
55 44
                ->end()
56 44
                ->scalarNode('persister')
57 44
                    ->info('The service name to use in the unit of work to persist the entity container')
58 44
                    ->defaultValue('innmind_neo4j.persister.delegation')
59 44
                ->end()
60 44
                ->scalarNode('metadata_configuration')
61 44
                    ->info('The service to use to validate a metadata configuration')
62 44
                    ->defaultValue('innmind_neo4j.metadata_builder.configuration')
63 44
                ->end()
64 44
            ->end();
65
66 44
        return $treeBuilder;
67
    }
68
}
69