Completed
Push — master ( 480903...23f69a )
by Nikola
06:55
created

Configuration   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 79
ccs 54
cts 60
cp 0.9
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 73 5
1
<?php
2
/*
3
 * This file is part of the  TraitorBundle, an RunOpenCode project.
4
 *
5
 * (c) 2016 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\Bundle\Traitor\DependencyInjection;
11
12
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
13
use Symfony\Component\Config\Definition\ConfigurationInterface;
14
15
class Configuration implements ConfigurationInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 4
    public function getConfigTreeBuilder()
21
    {
22 4
        $treeBuilder = new TreeBuilder();
23
24 4
        $rootNode = $treeBuilder->root('run_open_code_traitor');
25
26
        $rootNode
27 4
            ->addDefaultsIfNotSet()
28 4
            ->children()
29 4
                ->booleanNode('use_common_traits')
30 4
                    ->defaultFalse()
31 4
                    ->info('For sake of productivity, some of the common Symfony and vendor traits, as well as traits from this library, can be automatically added to "inject" definition.')
32 4
                ->end()
33 4
                ->arrayNode('inject')
34 4
                    ->useAttributeAsKey('trait')
35 4
                    ->prototype('array')
36 4
                        ->validate()
37 4
                            ->ifTrue(function($value) {
38
39
                                if (!is_array($value) || 2 !== count($value)) {
40 1
                                    return true;
41
                                }
42
43
                                if (!is_string($value[0])) {
44
                                    return true;
45
                                }
46
47
                                if (!is_array($value[1])) {
48
                                    return true;
49
                                }
50
51
                                return false;
52 4
                            })
53 4
                            ->thenInvalid('Expected proper setter injection definition.')
54 4
                        ->end()
55 4
                        ->prototype('variable')
56 4
                        ->end()
57 4
                    ->end()
58 4
                ->end()
59 4
                ->arrayNode('filters')
60 4
                    ->info('Analyse services for injection which matches filter criteria.')
61 4
                    ->children()
62 4
                        ->arrayNode('tags')
63 4
                            ->prototype('scalar')
64 4
                            ->end()
65 4
                        ->end()
66 4
                        ->arrayNode('namespaces')
67 4
                            ->prototype('scalar')
68 4
                            ->end()
69 4
                        ->end()
70 4
                    ->end()
71 4
                ->end()
72 4
                ->arrayNode('exclude')
73 4
                    ->info('Exclude services from injection which matches filter criteria.')
74 4
                    ->children()
75 4
                        ->arrayNode('services')
76 4
                            ->prototype('scalar')
77 4
                            ->end()
78 4
                        ->end()
79 4
                        ->arrayNode('namespaces')
80 4
                            ->prototype('scalar')
81 4
                            ->end()
82 4
                        ->end()
83 4
                        ->arrayNode('classes')
84 4
                            ->prototype('scalar')
85 4
                            ->end()
86 4
                        ->end()
87 4
                    ->end()
88 4
                ->end()
89 4
            ->end();
90
91 4
        return $treeBuilder;
92
    }
93
}
94