Passed
Push — master ( a6dc76...6d79cb )
by Guilherme
01:12 queued 11s
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 72
Code Lines 59

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 59
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 59
nc 1
nop 0
dl 0
loc 72
ccs 59
cts 59
cp 1
crap 1
rs 8.8945
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
namespace LoginCidadao\PhoneVerificationBundle\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 4
    public function getConfigTreeBuilder()
19
    {
20 4
        $treeBuilder = new TreeBuilder();
21 4
        $rootNode = $treeBuilder->root('login_cidadao_phone_verification');
22
23
        $rootNode
24 4
            ->children()
25 4
                ->booleanNode('enabled')
26 4
                    ->defaultFalse()
27 4
                ->end()
28
                // User's will HAVE TO verify their phone number after X accounts are using it
29 4
                ->scalarNode('require_validation_threshold')
30 4
                    ->defaultValue(3)
31 4
                ->end()
32 4
                ->arrayNode('verification_code')
33 4
                    ->addDefaultsIfNotSet()
34 4
                    ->children()
35 4
                        ->integerNode('length')
36 4
                            ->defaultValue(6)
37 4
                        ->end()
38 4
                        ->booleanNode('use_numbers')
39 4
                            ->defaultTrue()
40 4
                        ->end()
41 4
                        ->booleanNode('case_sensitive')
42 4
                            ->defaultFalse()
43 4
                        ->end()
44 4
                        ->booleanNode('use_lower')
45 4
                            ->defaultFalse()
46 4
                        ->end()
47 4
                        ->booleanNode('use_upper')
48 4
                            ->defaultFalse()
49 4
                        ->end()
50 4
                    ->end()
51 4
                ->end()
52
53 4
                ->arrayNode('verification_token')
54 4
                    ->addDefaultsIfNotSet()
55 4
                    ->children()
56 4
                        ->integerNode('length')
57 4
                            ->defaultValue(6)
58 4
                        ->end()
59 4
                    ->end()
60 4
                ->end()
61
62 4
                ->arrayNode('sms')
63 4
                    ->addDefaultsIfNotSet()
64 4
                    ->children()
65 4
                        ->scalarNode('resend_timeout')
66 4
                            ->defaultValue('+5 minutes')
67 4
                        ->end()
68 4
                    ->end()
69 4
                ->end()
70
71 4
                ->arrayNode('blocklist')
72 4
                    ->addDefaultsIfNotSet()
73 4
                    ->children()
74 4
                        ->booleanNode('enable_auto_block')
75 4
                            ->defaultValue(true)
76 4
                        ->end()
77
                        // A phone will get block-listed after X accounts are using it
78 4
                        ->scalarNode('auto_block_limit')
79 4
                            ->defaultValue(10)
80 4
                        ->end()
81 4
                    ->end()
82 4
                ->end()
83 4
            ->end();
84
85
        // Here you should define the parameters that are allowed to
86
        // configure your bundle. See the documentation linked above for
87
        // more information on that topic.
88
89 4
        return $treeBuilder;
90
    }
91
}
92