Completed
Pull Request — master (#71)
by
unknown
02:34
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 55
Code Lines 50

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 2
Metric Value
c 5
b 0
f 2
dl 0
loc 55
rs 9.7692
cc 1
eloc 50
nc 1
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 Sonata\SeoBundle\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
class Configuration implements ConfigurationInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function getConfigTreeBuilder()
17
    {
18
        $treeBuilder = new TreeBuilder();
19
20
        $treeBuilder->root('sonata_seo')
21
            ->children()
22
                ->scalarNode('encoding')->defaultValue('UTF-8')->end()
23
                ->arrayNode('page')
24
                    ->addDefaultsIfNotSet()
25
                    ->children()
26
                        ->scalarNode('default')->defaultValue('sonata.seo.page.default')->end()
27
                        ->arrayNode('head')
28
                            ->normalizeKeys(false)
29
                            ->useAttributeAsKey('attribute')
30
                            ->prototype('scalar')->end()
31
                        ->end()
32
                        ->arrayNode('html_tag')
33
                            ->normalizeKeys(false)
34
                            ->useAttributeAsKey('attribute')
35
                            ->prototype('scalar')->end()
36
                        ->end()
37
                        ->arrayNode('head_tag')
38
                            ->normalizeKeys(false)
39
                            ->useAttributeAsKey('attribute')
40
                            ->prototype('scalar')->end()
41
                        ->end()
42
                        ->arrayNode('metas')
43
                            ->normalizeKeys(false)
44
                            ->useAttributeAsKey('element')
45
                            ->prototype('array')
46
                                ->normalizeKeys(false)
47
                                ->useAttributeAsKey('name')
48
                                ->prototype('scalar')->end()
49
                            ->end()
50
                        ->end()
51
                        ->scalarNode('separator')->defaultValue(' - ')->end()
52
                        ->scalarNode('title')->defaultValue('Sonata Project')->end()
53
                    ->end()
54
                ->end()
55
                ->arrayNode('sitemap')
56
                    ->addDefaultsIfNotSet()
57
                    ->children()
58
                        ->arrayNode('doctrine_orm')
59
                            ->prototype('variable')->end()
60
                        ->end()
61
                        ->arrayNode('services')
62
                            ->prototype('variable')->end()
63
                        ->end()
64
                    ->end()
65
                ->end()
66
            ->end()
67
        ;
68
69
        return $treeBuilder;
70
    }
71
}
72