Completed
Push — master ( d17154...1fc820 )
by Sullivan
11:02 queued 08:59
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 59
Code Lines 55

Duplication

Lines 0
Ratio 0 %

Importance

Changes 8
Bugs 0 Features 5
Metric Value
c 8
b 0
f 5
dl 0
loc 59
rs 9.597
cc 1
eloc 55
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
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\TranslationBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15
use Symfony\Component\Config\Definition\ConfigurationInterface;
16
17
/**
18
 * @author Nicolas Bastien <[email protected]>
19
 */
20
class Configuration implements ConfigurationInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function getConfigTreeBuilder()
26
    {
27
        $treeBuilder = new TreeBuilder();
28
        $rootNode = $treeBuilder->root('sonata_translation');
29
30
        $rootNode
31
            ->children()
32
                ->arrayNode('locales')
33
                    ->info('The list of your frontend locales in which your models will be translatable.')
34
                    ->requiresAtLeastOneElement()
35
                    ->prototype('scalar')->end()
36
                ->end()
37
                ->scalarNode('default_locale')
38
                    ->defaultValue('en')
39
                    ->info('The frontend locale that is used by default.')
40
                ->end()
41
                ->arrayNode('gedmo')
42
                    ->canBeEnabled()
43
                    ->children()
44
                        ->arrayNode('implements')
45
                            ->requiresAtLeastOneElement()
46
                            ->prototype('scalar')->end()
47
                        ->end()
48
                        ->arrayNode('instanceof')
49
                            ->requiresAtLeastOneElement()
50
                            ->prototype('scalar')->end()
51
                        ->end()
52
                    ->end()
53
                ->end()
54
                ->arrayNode('knplabs')
55
                    ->canBeEnabled()
56
                    ->children()
57
                        ->arrayNode('implements')
58
                            ->requiresAtLeastOneElement()
59
                            ->prototype('scalar')->end()
60
                        ->end()
61
                        ->arrayNode('instanceof')
62
                            ->requiresAtLeastOneElement()
63
                            ->prototype('scalar')->end()
64
                        ->end()
65
                    ->end()
66
                ->end()
67
                ->arrayNode('phpcr')
68
                    ->canBeEnabled()
69
                    ->children()
70
                        ->arrayNode('implements')
71
                            ->requiresAtLeastOneElement()
72
                            ->prototype('scalar')->end()
73
                        ->end()
74
                        ->arrayNode('instanceof')
75
                            ->requiresAtLeastOneElement()
76
                            ->prototype('scalar')->end()
77
                        ->end()
78
                    ->end()
79
                ->end()
80
            ->end();
81
82
        return $treeBuilder;
83
    }
84
}
85