Completed
Push — master ( 647efd...c7681f )
by Jeroen
38:40 queued 32:44
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 57

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 45
CRAP Score 2.0003

Importance

Changes 0
Metric Value
dl 0
loc 57
ccs 45
cts 47
cp 0.9574
rs 8.9381
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0003

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\NodeBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
9
/**
10
 * This is the class that validates and merges configuration from your app/config files
11
 *
12
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
13
 */
14
class Configuration implements ConfigurationInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19 2
    public function getConfigTreeBuilder()
20
    {
21 2
        $treeBuilder = new TreeBuilder('kunstmaan_node');
22 2
        if (method_exists($treeBuilder, 'getRootNode')) {
23 2
            $rootNode = $treeBuilder->getRootNode();
24
        } else {
25
            // BC layer for symfony/config 4.1 and older
26
            $rootNode = $treeBuilder->root('kunstmaan_node');
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\Config...der\TreeBuilder::root() has been deprecated with message: since Symfony 4.3, pass the root name to the constructor instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
27
        }
28
29
        /* @var ArrayNodeDefinition $pages */
30
        $rootNode
31 2
            ->children()
32 2
                ->arrayNode('pages')
33 2
                    ->prototype('array')
34 2
                        ->children()
35 2
                            ->scalarNode('name')->isRequired()->end()
36 2
                            ->scalarNode('search_type')->end()
37 2
                            ->booleanNode('structure_node')->end()
38 2
                            ->booleanNode('indexable')->end()
39 2
                            ->scalarNode('icon')->defaultNull()->end()
40 2
                            ->scalarNode('hidden_from_tree')->end()
41 2
                            ->booleanNode('is_homepage')->end()
42 2
                            ->arrayNode('allowed_children')
43 2
                                ->prototype('array')
44 2
                                    ->beforeNormalization()
45
                                        ->ifString()->then(function ($v) {
46
                                            return ['class' => $v];
47 2
                                        })
48 2
                                    ->end()
49 2
                                    ->children()
50 2
                                        ->scalarNode('class')->isRequired()->end()
51 2
                                        ->scalarNode('name')->end()
52 2
                                    ->end()
53 2
                                ->end()
54 2
                            ->end()
55 2
                        ->end()
56 2
                    ->end()
57 2
                ->end()
58 2
                ->booleanNode('enable_permissions')->defaultTrue()->end()
59 2
                ->scalarNode('publish_later_stepping')->defaultValue('15')->end()
60 2
                ->scalarNode('unpublish_later_stepping')->defaultValue('15')->end()
61 2
                ->booleanNode('show_add_homepage')->defaultTrue()->end()
62 2
                ->booleanNode('enable_export_page_template')->defaultFalse()->end()
63 2
                ->arrayNode('lock')
64 2
                    ->addDefaultsIfNotSet()
65 2
                    ->canBeEnabled()
66 2
                    ->children()
67 2
                        ->scalarNode('check_interval')->defaultValue(15)->end()
68 2
                        ->scalarNode('threshold')->defaultValue(35)->end()
69 2
                        ->booleanNode('enabled')->defaultFalse()->end()
70 2
                    ->end()
71 2
                ->end()
72 2
            ->end();
73
74 2
        return $treeBuilder;
75
    }
76
}
77