Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 2

Test Coverage

Coverage 100%
Metric Value
wmc 1
cbo 2
dl 0
loc 35
ccs 24
cts 24
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 29 1
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\XApi\Bundle\ClientBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15
use Symfony\Component\Config\Definition\ConfigurationInterface;
16
17
/**
18
 * XApi client bundle configuration.
19
 *
20
 * @author Christian Flothmann <[email protected]>
21
 */
22
class Configuration implements ConfigurationInterface
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27 9
    public function getConfigTreeBuilder()
28
    {
29 9
        $treeBuilder = new TreeBuilder();
30 9
        $rootNode = $treeBuilder->root('xabbuh_xapi_client');
31
32
        $rootNode
33 9
            ->fixXmlConfig('client')
34 9
            ->children()
35 9
                ->arrayNode('clients')
36 9
                    ->useAttributeAsKey('name')
37 9
                    ->prototype('array')
38 9
                        ->children()
39 9
                            ->scalarNode('base_url')->isRequired()->end()
40 9
                            ->scalarNode('username')->end()
41 9
                            ->scalarNode('password')->end()
42 9
                            ->scalarNode('version')
43 9
                                ->defaultValue('1.0.1')
44 9
                                ->validate()
45 9
                                    ->ifNotInArray(array('1.0.0', '1.0.1'))
46 9
                                    ->thenInvalid('Version must be on of 1.0.0, 1.0.1')
47 9
                                ->end()
48 9
                            ->end()
49 9
                        ->end()
50 9
                    ->end()
51 9
                ->end()
52 9
            ->end();
53
54 9
        return $treeBuilder;
55
    }
56
}
57