Completed
Push — master ( 7c1eaa...80d841 )
by Joachim
15:53
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 60
Code Lines 55

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 60
c 0
b 0
f 0
rs 9.5555
cc 1
eloc 55
nc 1
nop 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 Loevgaard\DandomainAltapayBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
class Configuration implements ConfigurationInterface
9
{
10
    public function getConfigTreeBuilder()
11
    {
12
        $treeBuilder = new TreeBuilder();
13
        $rootNode = $treeBuilder->root('loevgaard_dandomain_altapay');
14
15
        $rootNode
16
            ->children()
17
                ->scalarNode('altapay_username')
18
                    ->isRequired()
19
                    ->cannotBeEmpty()
20
                ->end()
21
                ->scalarNode('altapay_password')
22
                    ->isRequired()
23
                    ->cannotBeEmpty()
24
                ->end()
25
                ->arrayNode('altapay_ips')
26
                    ->isRequired()
27
                    ->requiresAtLeastOneElement()
28
                    ->prototype('scalar')->end()
29
                ->end()
30
                ->scalarNode('shared_key_1')
31
                    ->isRequired()
32
                    ->cannotBeEmpty()
33
                ->end()
34
                ->scalarNode('shared_key_2')
35
                    ->isRequired()
36
                    ->cannotBeEmpty()
37
                ->end()
38
                ->scalarNode('terminal_class')
39
                    ->isRequired()
40
                    ->cannotBeEmpty()
41
                ->end()
42
                ->scalarNode('callback_class')
43
                    ->isRequired()
44
                    ->cannotBeEmpty()
45
                ->end()
46
                ->scalarNode('http_transaction_class')
47
                    ->isRequired()
48
                    ->cannotBeEmpty()
49
                ->end()
50
                ->scalarNode('payment_class')
51
                    ->isRequired()
52
                    ->cannotBeEmpty()
53
                ->end()
54
                ->scalarNode('payment_line_class')
55
                    ->isRequired()
56
                    ->cannotBeEmpty()
57
                ->end()
58
                ->scalarNode('cookie_payment_id')
59
                    ->defaultValue('payment_id')
60
                ->end()
61
                ->scalarNode('cookie_checksum_complete')
62
                    ->defaultValue('checksum_complete')
63
                ->end()
64
            ->end()
65
            ->fixXmlConfig('altapay_ip')
66
        ;
67
68
        return $treeBuilder;
69
    }
70
}
71