Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 58
Code Lines 55

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 58
rs 9.639
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
namespace NVBooster\PHPCRAssetsBundle\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();
21
        $rootNode = $treeBuilder->root('nvbooster_assets');
22
        $rootNode            
23
            ->children()            
24
                ->arrayNode('phpcr')
25
                    ->addDefaultsIfNotSet()
26
                    ->children()
27
                        ->scalarNode('root_path')
28
                            ->info('Defines path in PHPCR tree for assets to store in')
29
                            ->defaultValue('')
30
                        ->end()
31
                    ->end()
32
                ->end()
33
                ->arrayNode('filters')
34
                    ->addDefaultsIfNotSet()
35
                    ->info('Defines default filters for asset types')
36
                    ->fixXmlConfig('filter', 'css')
37
                    ->fixXmlConfig('filter', 'js')
38
                    ->children()
39
                        ->arrayNode('css')
40
                            ->addDefaultsIfNotSet()
41
                        ->end()
42
                        ->arrayNode('js')
43
                            ->addDefaultsIfNotSet()
44
                        ->end()
45
                    ->end()
46
                ->end()
47
                ->arrayNode('routing')
48
                    ->addDefaultsIfNotSet()
49
                    ->children()
50
                        ->scalarNode('base_uri')
51
                            ->info('Defines base uri for routes generated')
52
                            ->defaultValue('assets')
53
                        ->end()
54
                    ->end()
55
                ->end()
56
                ->arrayNode('codemirror')
57
                    ->info('Configuring codemirror js library (external)')
58
                    ->children()
59
                        ->arrayNode('paths')
60
                            ->children()
61
                                ->scalarNode('js')->end()
62
                                ->scalarNode('css')->end()
63
                                ->scalarNode('modes_dir')->end()
64
                                ->scalarNode('themes_dir')->end()
65
                            ->end()
66
                        ->end()
67
                        ->arrayNode('options')                            
68
                            ->prototype('scalar')->end()
69
                        ->end()
70
                    ->end()
71
                ->end()
72
            ->end();
73
            
74
        return $treeBuilder;
75
    }
76
}
77