Completed
Push — master ( 5f07d4...2f8908 )
by Nikola
03:06
created

Configuration   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 78.26%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 7
c 3
b 1
f 1
lcom 0
cbo 2
dl 0
loc 86
ccs 36
cts 46
cp 0.7826
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C getConfigTreeBuilder() 0 80 7
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
                                foreach ($value[1] as $arg) {
52
53
                                    if (!is_string($arg)) {
54
                                        return true;
55
                                    }
56
                                }
57
58
                                return false;
59 4
                            })
60 4
                            ->thenInvalid('Expected proper setter injection definition.')
61 4
                        ->end()
62 4
                        ->prototype('variable')
63 4
                        ->end()
64 4
                    ->end()
65 4
                ->end()
66 4
                ->arrayNode('filters')
67 4
                    ->info('Analyse services for injection which matches filter criteria.')
68 4
                    ->children()
69 4
                        ->arrayNode('tags')
70 4
                            ->prototype('scalar')
71 4
                            ->end()
72 4
                        ->end()
73 4
                        ->arrayNode('namespaces')
74 4
                            ->prototype('scalar')
75 4
                            ->end()
76 4
                        ->end()
77 4
                    ->end()
78 4
                ->end()
79
                ->arrayNode('exclude')
80 4
                    ->info('Exclude services from injection which matches filter criteria.')
81
                    ->children()
82
                        ->arrayNode('services')
83
                            ->prototype('scalar')
84
                            ->end()
85
                        ->end()
86
                        ->arrayNode('namespaces')
87
                            ->prototype('scalar')
88
                            ->end()
89
                        ->end()
90
                        ->arrayNode('classes')
91
                            ->prototype('scalar')
92
                            ->end()
93
                        ->end()
94
                    ->end()
95
                ->end()
96
            ->end();
97
98
        return $treeBuilder;
99
    }
100
}
101