Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 24 2
1
<?php
2
3
namespace GBProd\ElasticaSpecificationBundle\DependencyInjection;
4
5
use Elastica\QueryBuilder\Version;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
9
10
/**
11
 * Configuration
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15
class Configuration implements ConfigurationInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 9
    public function getConfigTreeBuilder()
21
    {
22 9
        $treeBuilder = new TreeBuilder();
23 9
        $root = $treeBuilder->root('elastica_specification_bundle');
24
25
        $root
26 9
            ->children()
27 9
                ->scalarNode('dsl_version')
28 9
                    ->defaultValue('Latest')
29 9
                    ->cannotBeEmpty()
30 9
                    ->beforeNormalization()
31 9
                        ->ifTrue(function($value) {
32 3
                            return !is_string($value)
33 3
                                || !class_exists('Elastica\\QueryBuilder\\Version\\'.$value)
34
                            ;
35 9
                        })
36 9
                        ->thenInvalid('QueryBuilder version "%s" does not exists')
37 9
                    ->end()
38 9
                ->end()
39 9
            ->end()
40
        ;
41
42 9
        return $treeBuilder;
43
    }
44
}
45