Passed
Push — master ( f75ef5...782b7a )
by Matthieu
05:01
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 65
Code Lines 60

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 60
nc 1
nop 0
dl 0
loc 65
rs 8.8727
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
declare(strict_types=1);
4
5
namespace AtlassianConnectBundle\DependencyInjection;
6
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\ConfigurationInterface;
9
10
class Configuration implements ConfigurationInterface
11
{
12
    public function getConfigTreeBuilder(): TreeBuilder
13
    {
14
        $treeBuilder = new TreeBuilder('atlassian_connect');
15
        $rootNode = $treeBuilder->getRootNode();
16
17
        $rootNode
18
            ->children()
19
                ->variableNode('dev_tenant')->defaultValue(1)->end()
20
                ->arrayNode('descriptor')
21
                    ->ignoreExtraKeys()
22
                    ->children()
23
                        ->arrayNode('authentication')
24
                            ->addDefaultsIfNotSet()
25
                            ->children()
26
                                ->enumNode('type')->values(['jwt', 'none', 'JWT', 'NONE'])->defaultValue('jwt')->isRequired()->end()
27
                            ->end()
28
                        ->end()
29
                        ->scalarNode('baseUrl')->isRequired()->cannotBeEmpty()->end()
30
                        ->scalarNode('key')->isRequired()->cannotBeEmpty()->end()
31
                        ->integerNode('apiVersion')->end()
32
                        ->scalarNode('name')->end()
33
                        ->scalarNode('description')->end()
34
                        ->booleanNode('enableLicensing')->end()
35
                        ->arrayNode('lifecycle')
36
                            ->children()
37
                                ->scalarNode('installed')->end()
38
                                ->scalarNode('enabled')->end()
39
                                ->scalarNode('disabled')->end()
40
                                ->scalarNode('uninstalled')->end()
41
                            ->end()
42
                        ->end()
43
                        ->arrayNode('vendor')
44
                            ->children()
45
                                ->scalarNode('name')->end()
46
                                ->scalarNode('url')->end()
47
                            ->end()
48
                        ->end()
49
                        ->arrayNode('scopes')
50
                            ->scalarPrototype()->end()
51
                        ->end()
52
                        ->variableNode('links')
53
                        ->end()
54
                        ->variableNode('modules')
55
                        ->end()
56
                        ->arrayNode('translations')
57
                            ->children()
58
                                ->arrayNode('paths')
59
                                    ->scalarPrototype()->end()
60
                                ->end()
61
                            ->end()
62
                        ->end()
63
                    ->end()
64
                ->end()
65
                ->arrayNode('license_allow_list')
66
                    ->arrayPrototype()
67
                        ->children()
68
                            ->scalarNode('client_key')->end()
69
                            ->scalarNode('valid_till')->end()
70
                        ->end()
71
                    ->end()
72
                ->end()
73
            ->end()
74
        ;
75
76
        return $treeBuilder;
77
    }
78
}
79