Completed
Pull Request — master (#34)
by
unknown
02:45
created

Configuration   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 11
Bugs 1 Features 3
Metric Value
c 11
b 1
f 3
dl 0
loc 58
wmc 3
lcom 0
cbo 3
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 31 2
A buildDefinitionBuilderNode() 0 15 1
1
<?php
2
3
namespace Knp\Rad\AutoRegistration\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
9
class Configuration implements ConfigurationInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function getConfigTreeBuilder()
15
    {
16
        $builders = [
17
            'constraint_validator',
18
            'doctrine',
19
            'doctrine_mongodb',
20
            'form_type_extension',
21
            'security_voter',
22
            'twig_extension',
23
        ];
24
25
        $nodes = new ArrayNodeDefinition('enable');
26
27
        foreach ($builders as $builder) {
28
            $nodes->children()->append($this->buildDefinitionBuilderNode($builder));
29
        }
30
31
        $builder = new TreeBuilder();
32
        $builder
33
            ->root('knp_rad_auto_registration')
34
            ->children()
35
                ->append($nodes)
36
                ->arrayNode('bundles')
37
                    ->prototype('scalar')->end()
38
                    ->defaultValue([])
39
                ->end()
40
            ->end()
41
        ;
42
43
        return $builder;
44
    }
45
46
    /**
47
     * @param string $name
48
     *
49
     * @return ArrayNodeDefinition
50
     */
51
    private function buildDefinitionBuilderNode($name)
52
    {
53
        $node = new ArrayNodeDefinition($name);
54
55
        $node
56
            ->children()
57
                ->booleanNode('public')
58
                    ->defaultFalse()
59
                    ->treatNullLike(false)
60
                ->end()
61
            ->end()
62
        ;
63
64
        return $node;
65
    }
66
}
67