Completed
Push — develop ( c09436...2e7522 )
by Baptiste
02:59
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 55
Code Lines 51

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 50
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 55
ccs 50
cts 50
cp 1
rs 9.7692
cc 1
eloc 51
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
final class Configuration implements ConfigurationInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 24
    public function getConfigTreeBuilder()
18
    {
19 24
        $treeBuilder = new TreeBuilder;
20 24
        $root = $treeBuilder->root('innmind_neo4j');
21
22
        $root
23 24
            ->children()
24 24
                ->arrayNode('connection')
25 24
                    ->addDefaultsIfNotSet()
26 24
                    ->children()
27 24
                        ->scalarNode('host')
28 24
                            ->defaultValue('localhost')
29 24
                        ->end()
30 24
                        ->scalarNode('scheme')
31 24
                            ->defaultValue('https')
32 24
                        ->end()
33 24
                        ->integerNode('port')
34 24
                            ->defaultValue(7474)
35 24
                        ->end()
36 24
                        ->scalarNode('user')
37 24
                            ->defaultValue('neo4j')
38 24
                        ->end()
39 24
                        ->scalarNode('password')
40 24
                            ->defaultValue('neo4j')
41 24
                        ->end()
42 24
                    ->end()
43 24
                ->end()
44 24
                ->arrayNode('types')
45 24
                    ->defaultValue([])
46 24
                    ->prototype('scalar')->end()
47 24
                ->end()
48 24
                ->scalarNode('persister')
49 24
                    ->info('The service name to use in the unit of work to persist the entity container')
50 24
                    ->defaultValue('innmind_neo4j.persister.delegation')
51 24
                ->end()
52 24
                ->scalarNode('metadata_configuration')
53 24
                    ->info('The service to use to validate a metadata configuration')
54 24
                    ->defaultValue('innmind_neo4j.metadata_builder.configuration')
55 24
                ->end()
56 24
                ->scalarNode('clock')
57 24
                    ->info('The clock service to use (instance of TimeContinuumInterface)')
58 24
                    ->defaultValue('innmind_neo4j.clock')
59 24
                ->end()
60 24
                ->scalarNode('event_bus')
61 24
                    ->info('The event bus service to use for persisters')
62 24
                    ->defaultValue('innmind_neo4j.event_bus.null')
63 24
                ->end()
64 24
                ->scalarNode('dbal_connection')
65 24
                    ->info('The dbal connection service to use')
66 24
                    ->defaultValue('innmind_neo4j.dbal.connection.logger')
67 24
                ->end()
68 24
            ->end();
69
70 24
        return $treeBuilder;
71
    }
72
}
73