Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 54
ccs 41
cts 41
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 48 2
1
<?php
2
3
namespace GBProd\ElasticaBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * Configuration
10
 *
11
 * @author gbprod <[email protected]>
12
 */
13
class Configuration implements ConfigurationInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 12
    public function getConfigTreeBuilder()
19
    {
20 12
        $treeBuilder = new TreeBuilder();
21 12
        $rootNode = $treeBuilder->root('elastica_bundle');
22
23
        $rootNode
24 12
            ->children()
25 12
                ->scalarNode('logger')
26 12
                    ->defaultValue('logger')
27 12
                ->end()
28 12
                ->arrayNode('clients')
29 12
                    ->useAttributeAsKey('id')
30 12
                    ->defaultValue([])
31 12
                    ->prototype('array')
32 12
                        ->beforeNormalization()
33
                            ->ifTrue(function($values) {
34 6
                                return is_array($values) && !array_key_exists('connections', $values);
35 12
                            })
36 12
                            ->then(function($values) {
37 4
                                return ['connections' => [$values]];
38 12
                            })
39 12
                        ->end()
40 12
                        ->children()
41 12
                            ->arrayNode('connections')
42 12
                                ->requiresAtLeastOneElement()
43 12
                                ->prototype('array')
44 12
                                    ->addDefaultsIfNotSet()
45 12
                                    ->children()
46 12
                                        ->scalarNode('host')->defaultValue('127.0.0.1')->end()
47 12
                                        ->scalarNode('port')->defaultValue(9200)->end()
48 12
                                        ->scalarNode('path')->defaultNull()->end()
49 12
                                        ->scalarNode('url')->defaultNull()->end()
50 12
                                        ->scalarNode('proxy')->defaultNull()->end()
51 12
                                        ->scalarNode('transport')->defaultNull()->end()
52 12
                                        ->scalarNode('persistent')->defaultTrue()->end()
53 12
                                        ->scalarNode('timeout')->defaultNull()->end()
54 12
                                    ->end()
55 12
                                ->end()
56 12
                            ->end()
57 12
                        ->end()
58 12
                    ->end()
59 12
                ->end()
60 12
                ->booleanNode('autowire')->defaultTrue()->end()
61 12
            ->end()
62
        ;
63
64 12
        return $treeBuilder;
65
    }
66
}
67