Completed
Push — master ( 3081d8...0e5b16 )
by Ruud
43:38 queued 29:10
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 55

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 55
rs 8.9818
c 0
b 0
f 0
cc 2
nc 2
nop 0

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 Kunstmaan\MultiDomainBundle\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
    public function getConfigTreeBuilder()
19
    {
20
        $treeBuilder = new TreeBuilder('kunstmaan_multi_domain');
21
        if (method_exists($treeBuilder, 'getRootNode')) {
22
            $rootNode = $treeBuilder->getRootNode();
23
        } else {
24
            // BC layer for symfony/config 4.1 and older
25
            $rootNode = $treeBuilder->root('kunstmaan_multi_domain');
26
        }
27
28
        $rootNode
29
            ->children()
30
                ->arrayNode('hosts')
31
                    ->isRequired()
32
                    ->requiresAtLeastOneElement()
33
                    // ->useAttributeAsKey('host')
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
                    ->prototype('array')
35
                        ->children()
36
                            ->scalarNode('host')
37
                                ->isRequired()
38
                            ->end()
39
                            ->scalarNode('protocol')
40
                                ->defaultValue('http')
41
                            ->end()
42
                            ->arrayNode('aliases')
43
                                ->prototype('scalar')->end()
44
                            ->end()
45
                            ->scalarNode('type')
46
                                ->defaultValue('single_lang')
47
                            ->end()
48
                            ->scalarNode('root')
49
                                ->defaultValue('homepage')
50
                            ->end()
51
                            ->variableNode('extra')
52
                            ->end()
53
                            ->scalarNode('default_locale')
54
                                ->isRequired()
55
                            ->end()
56
                            ->arrayNode('locales')
57
                                ->isRequired()
58
                                ->requiresAtLeastOneElement()
59
                                ->prototype('array')
60
                                    ->children()
61
                                        ->scalarNode('uri_locale')->isRequired()->end()
62
                                        ->scalarNode('locale')->isRequired()->end()
63
                                        ->variableNode('extra')->end()
64
                                    ->end()
65
                                ->end()
66
                            ->end()
67
                        ->end()
68
                ->end()
69
            ->end();
70
71
        return $treeBuilder;
72
    }
73
}
74