Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 52
Code Lines 46

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 46
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 46
c 1
b 0
f 0
dl 0
loc 52
ccs 46
cts 46
cp 1
rs 9.1781
cc 1
nc 1
nop 0
crap 1

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 Deamon\LoggerExtraBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * This is the class that validates and merges configuration from your app/config files.
10
 *
11
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
12
 */
13
class Configuration implements ConfigurationInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 3
    public function getConfigTreeBuilder(): TreeBuilder
19
    {
20 3
        $treeBuilder = new TreeBuilder('deamon_logger_extra');
21
22 3
        $treeBuilder->getRootNode()->children()
23 3
            ->arrayNode('application')->isRequired()
24 3
            ->children()
25 3
            ->scalarNode('name')->defaultNull()->cannotBeEmpty()->end()
26 3
            ->scalarNode('locale')->defaultNull()->end()
27 3
            ->scalarNode('version')->defaultNull()->end()
28 3
            ->end()
29 3
            ->end()
30 3
            ->arrayNode('handlers')->isRequired()
31 3
            ->beforeNormalization()
32 3
            ->ifString()
33 3
            ->then(function($v) {
34 1
                return array($v);
35
            })
36 3
            ->end()
37 3
            ->prototype('scalar')->isRequired()->cannotBeEmpty()->end()
38 3
            ->end()
39 3
            ->arrayNode('config')->isRequired()->addDefaultsIfNotSet()
40 3
            ->children()
41 3
            ->scalarNode('channel_prefix')->defaultNull()->end()
42 3
            ->scalarNode('user_class')->defaultValue(null)->end()
43 3
            ->arrayNode('user_methods')
44 3
            ->useAttributeAsKey('value')
45 3
            ->normalizeKeys(false)
46 3
            ->defaultValue(array(
47
                'user_name' => 'getUsername',
48
            ))
49 3
            ->prototype('scalar')->end()
50 3
            ->end()
51 3
            ->arrayNode('display')->addDefaultsIfNotSet()
52 3
            ->children()
53 3
            ->booleanNode('env')->defaultTrue()->end()
54 3
            ->booleanNode('locale')->defaultTrue()->end()
55 3
            ->booleanNode('application_name')->defaultTrue()->end()
56 3
            ->booleanNode('application_version')->defaultTrue()->end()
57 3
            ->booleanNode('url')->defaultTrue()->end()
58 3
            ->booleanNode('route')->defaultTrue()->end()
59 3
            ->booleanNode('user_agent')->defaultTrue()->end()
60 3
            ->booleanNode('accept_encoding')->defaultTrue()->end()
61 3
            ->booleanNode('client_ip')->defaultTrue()->end()
62 3
            ->booleanNode('user')->defaultTrue()->end()
63 3
            ->booleanNode('global_channel')->defaultFalse()->end()
64 3
            ->end()
65 3
            ->end()
66 3
            ->end()
67 3
            ->end();
68
69 3
        return $treeBuilder;
70
    }
71
}
72