Completed
Push — master ( 5fb806...0f3195 )
by Nicolas
21:50
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 23
rs 9.0856
cc 1
eloc 20
nc 1
nop 0
1
<?php
2
3
namespace NBN\LoadBalancerBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * @author Nicolas Bastien <[email protected]>
10
 */
11
class Configuration implements ConfigurationInterface
12
{
13
    /**
14
     * {@inheritDoc}
15
     */
16
    public function getConfigTreeBuilder()
17
    {
18
        $treeBuilder = new TreeBuilder();
19
        $rootNode = $treeBuilder->root('load_balancer');
20
        $rootNode
21
            ->children()
22
                ->scalarNode('host_chooser')->defaultValue('rotation')->end()
23
                ->scalarNode('load_limit')->defaultValue('0.5')->end()
24
                ->arrayNode('hosts')
25
                    ->useAttributeAsKey('id')
26
                    ->prototype('array')
27
                        ->children()
28
                            ->scalarNode('url')->end()
29
                            ->arrayNode('settings')
30
                                ->prototype('scalar')->end()
31
                            ->end()
32
                        ->end()
33
                    ->end()
34
                ->end()
35
            ->end();
36
37
        return $treeBuilder;
38
    }
39
}
40