Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 52
Code Lines 48

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 48
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 48
nc 1
nop 0
dl 0
loc 52
ccs 48
cts 48
cp 1
crap 1
rs 9.1344
c 0
b 0
f 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
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
7
namespace Zicht\Bundle\PageBundle\DependencyInjection;
8
9
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
10
use Symfony\Component\Config\Definition\ConfigurationInterface;
11
12
/**
13
 * Page bundle configuration
14
 */
15
class Configuration implements ConfigurationInterface
16
{
17
    /**
18
     * @{inheritDoc}
19
     */
20 1
    public function getConfigTreeBuilder()
21
    {
22 1
        $treeBuilder = new TreeBuilder();
23 1
        $rootNode = $treeBuilder->root('zicht_page');
24
25
        $rootNode
26 1
            ->children()
27 1
                ->arrayNode('aliasing')
28 1
                    ->canBeEnabled()
29 1
                    ->addDefaultsIfNotSet()
30 1
                    ->children()
31 1
                        ->scalarNode('service')->defaultValue('zicht_page.page_aliasing_strategy')->end()
32 1
                        ->arrayNode('prefixLanguages')->prototype('scalar')->end()->end()
33 1
                        ->scalarNode('conflictingInternalUrlStrategy')
34 1
                            ->defaultValue('ignore')
35 1
                            ->validate()
36 1
                            ->ifNotInArray(['ignore', 'redirect-previous-to-new'])
37 1
                                ->thenInvalid('Invalid conflictingInternalUrlStrategy')
38 1
                            ->end()
39 1
                        ->end()
40 1
                        ->scalarNode('conflictingPublicUrlStrategy')
41 1
                            ->defaultValue('suffix')
42 1
                            ->validate()
43 1
                            ->ifNotInArray(['keep', 'overwrite', 'suffix'])
44 1
                                ->thenInvalid('Invalid conflictingPublicUrlStrategy')
45 1
                            ->end()
46 1
                        ->end()
47 1
                    ->end()
48 1
                ->end()
49 1
                ->arrayNode('types')
50 1
                    ->isRequired()
51 1
                    ->children()
52 1
                        ->arrayNode('page')->prototype('scalar')->isRequired()->end()->end()
53 1
                        ->arrayNode('contentItem')->prototype('scalar')->isRequired()->end()->end()
54 1
                    ->end()
55 1
                ->end()
56 1
                ->scalarNode('pageClass')->isRequired()->end()
57 1
                ->scalarNode('contentItemClass')->isRequired()->end()
58 1
                ->arrayNode('admin')
59 1
                    ->children()
60 1
                        ->arrayNode('base')
61 1
                            ->children()
62 1
                                ->scalarNode('page')->end()
63 1
                                ->scalarNode('contentItem')->end()
64 1
                            ->end()
65 1
                        ->end()
66 1
                    ->end()
67 1
                ->end()
68 1
                ->arrayNode('defaultRegions')->prototype('scalar')->isRequired()->end()->end()
69 1
            ->end();
70
71 1
        return $treeBuilder;
72
    }
73
}
74