Completed
Pull Request — master (#2609)
by
unknown
05:53
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 74

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 26
CRAP Score 2.0002

Importance

Changes 0
Metric Value
dl 0
loc 74
ccs 26
cts 27
cp 0.963
rs 8.5672
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0002

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\MediaBundle\DependencyInjection;
4
5
use Kunstmaan\MediaBundle\Utils\SymfonyVersion;
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
     * Generates the configuration tree.
18
     *
19
     * @return TreeBuilder
20
     */
21 5
    public function getConfigTreeBuilder()
22
    {
23 5
        $treeBuilder = new TreeBuilder('kunstmaan_media');
24 5
        if (method_exists($treeBuilder, 'getRootNode')) {
25 5
            $rootNode = $treeBuilder->getRootNode();
26
        } else {
27
            // BC layer for symfony/config 4.1 and older
28
            $rootNode = $treeBuilder->root('kunstmaan_media');
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...
29
        }
30
31
        $rootNode
32 5
            ->children()
33 5
                ->scalarNode('soundcloud_api_key')->defaultValue('YOUR_CLIENT_ID')->end()
34 5
                ->scalarNode('aviary_api_key')->defaultNull()->end()
35 5
                ->arrayNode('remote_video')
36 5
                    ->addDefaultsIfNotSet()
37 5
                    ->children()
38 5
                        ->booleanNode('vimeo')->defaultTrue()->end()
39 5
                        ->booleanNode('youtube')->defaultTrue()->end()
40 5
                        ->booleanNode('dailymotion')->defaultTrue()->end()
41 5
                    ->end()
42 5
                ->end()
43 5
                ->booleanNode('enable_pdf_preview')->defaultFalse()->end()
44 5
                ->arrayNode('blacklisted_extensions')
45 5
                    ->defaultValue(['php', 'htaccess'])
46 5
                    ->prototype('scalar')->end()
47 5
                ->end()
48 5
                ->scalarNode('web_root')
49 5
                    ->defaultValue(SymfonyVersion::getRootWebPath())
50 5
                    ->cannotBeEmpty()
51 5
                ->end()
52 5
                ->arrayNode('cropping_views')
53
                    ->children()
54 5
                        ->arrayNode('default')
55
                            ->arrayPrototype()
56
                                ->addDefaultsIfNotSet()
57
                                ->children()
58
                                    ->scalarNode('name')->end()
59
                                    ->integerNode('width')->end()
60
                                    ->integerNode('height')->end()
61
                                    ->booleanNode('lockRatio')->defaultTrue()->end()
62
                                ->end()
63
                            ->end()
64
                        ->end()
65
                        ->arrayNode('focus_point_classes')
66
                            ->defaultValue(['top-left' ,'top-center', 'top-right', 'center-left', 'center', 'center-right', 'bottom-left', 'bottom-center', 'bottom-right'])
67
                            ->prototype('array')->end()
68
                        ->end()
69
                        ->arrayNode('custom_views')
70
                            ->useAttributeAsKey('groupName')
71
                            ->arrayPrototype()
72
                                ->addDefaultsIfNotSet()
73
                                ->children()
74
                                    ->booleanNode('useFocusPoint')->defaultFalse()->end()
75
                                    ->arrayNode('views')
76
                                        ->arrayPrototype()
77
                                            ->addDefaultsIfNotSet()
78
                                            ->children()
79
                                                ->scalarNode('name')->end()
80
                                                ->integerNode('width')->end()
81
                                                ->integerNode('height')->end()
82
                                                ->booleanNode('lockRatio')->defaultTrue()->end()
83
                                            ->end()
84
                                        ->end()
85
                                    ->end()
86
                                ->end()
87
                            ->end()
88
                        ->end()
89
                    ->end()
90
                ->end()
91
            ->end();
92
93
        return $treeBuilder;
94
    }
95
}
96