Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 61
Code Lines 47

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 2
eloc 47
c 4
b 0
f 0
nc 2
nop 0
dl 0
loc 61
rs 9.1563

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace DH\DoctrineAuditBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\ParentNodeDefinitionInterface;
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
        $treeBuilder = new TreeBuilder('dh_doctrine_audit');
17
18
        // Keep compatibility with symfony/config < 4.2
19
        /** @var ParentNodeDefinitionInterface $rootNode */
20
        $rootNode = method_exists($treeBuilder, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('dh_doctrine_audit');
21
22
        $rootNode
23
            ->children()
24
                ->scalarNode('enabled')
25
                    ->defaultTrue()
26
                ->end()
27
28
                ->scalarNode('enabled_viewer')
0 ignored issues
show
Bug introduced by
The method scalarNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
                ->/** @scrutinizer ignore-call */ scalarNode('enabled_viewer')
Loading history...
29
                    ->defaultTrue()
30
                ->end()
31
32
                ->scalarNode('storage_entity_manager')
33
                    ->cannotBeEmpty()
34
                    ->defaultNull()
35
                ->end()
36
37
                ->scalarNode('table_prefix')
38
                    ->defaultValue('')
39
                ->end()
40
                ->scalarNode('table_suffix')
41
                    ->defaultValue('_audit')
42
                ->end()
43
44
                ->arrayNode('ignored_columns')
45
                    ->canBeUnset()
46
                    ->prototype('scalar')->end()
47
                ->end()
48
49
                ->scalarNode('timezone')
50
                    ->defaultValue('UTC')
51
                ->end()
52
53
                ->arrayNode('entities')
54
                    ->canBeUnset()
55
                    ->prototype('array')
56
                        ->children()
57
                            ->arrayNode('ignored_columns')
58
                                ->canBeUnset()
59
                                ->prototype('scalar')->end()
60
                            ->end()
61
                            ->booleanNode('enabled')
62
                                ->defaultTrue()
63
                            ->end()
64
                            ->arrayNode('roles')
65
                                ->canBeUnset()
66
                                ->prototype('scalar')->end()
67
                            ->end()
68
                        ->end()
69
                    ->end()
70
                ->end()
71
            ->end()
72
        ;
73
74
        return $treeBuilder;
75
    }
76
}
77