Completed
Push — master ( 6c3722...239355 )
by Matthew
19:49 queued 17:50
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 71
Code Lines 66

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 71
ccs 0
cts 69
cp 0
rs 9.1369
c 0
b 0
f 0
cc 1
eloc 66
nc 1
nop 0
crap 2

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 Dtc\QueueBundle\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
    /**
11
     * Generates the configuration tree.
12
     *
13
     * @return TreeBuilder
14
     */
15
    public function getConfigTreeBuilder()
16
    {
17
        $treeBuilder = new TreeBuilder();
18
        $rootNode = $treeBuilder->root('dtc_queue');
19
20
        $rootNode
21
            ->children()
22
                ->scalarNode('document_manager')
23
                    ->defaultValue('default')
24
                    ->cannotBeEmpty()
25
                ->end()
26
                ->scalarNode('entity_manager')
27
                    ->defaultValue('default')
28
                    ->cannotBeEmpty()
29
                ->end()
30
                ->scalarNode('default_manager')
31
                    ->defaultValue('mongodb')
32
                    ->cannotBeEmpty()
33
                ->end()
34
                ->scalarNode('class_job')
35
                ->end()
36
                ->scalarNode('class_job_archive')
37
                ->end()
38
                ->scalarNode('class_run')
39
                ->end()
40
                ->scalarNode('class_run_archive')
41
                ->end()
42
                ->arrayNode('beanstalkd')
43
                    ->children()
44
                        ->scalarNode('host')->end()
45
                        ->scalarNode('tube')->end()
46
                    ->end()
47
                ->end()
48
                ->arrayNode('rabbit_mq')
49
                    ->children()
50
                        ->scalarNode('host')->end()
51
                        ->scalarNode('port')->end()
52
                        ->scalarNode('user')->end()
53
                        ->scalarNode('password')->end()
54
                        ->scalarNode('vhost')->defaultValue('/')->end()
55
                        ->booleanNode('ssl')->defaultFalse()->end()
56
                        ->scalarNode('options')->end()
57
                        ->scalarNode('ssl_options')->end()
58
                        ->arrayNode('queue_args')
59
                            ->addDefaultsIfNotSet()
60
                            ->children()
61
                                ->scalarNode('queue')->defaultValue('dtc_queue')->end()
62
                                ->booleanNode('passive')->defaultFalse()->end()
63
                                ->booleanNode('durable')->defaultTrue()->end()
64
                                ->booleanNode('exclusive')->defaultFalse()->end()
65
                                ->booleanNode('auto_delete')->defaultFalse()->end()
66
                                ->integerNode('max_priority')->defaultValue(255)->end()
67
                            ->end()
68
                        ->end()
69
                        ->arrayNode('exchange_args')
70
                            ->addDefaultsIfNotSet()
71
                            ->children()
72
                                ->scalarNode('exchange')->defaultValue('dtc_queue_exchange')->end()
73
                                ->booleanNode('type')->defaultValue('direct')->end()
74
                                ->booleanNode('passive')->defaultFalse()->end()
75
                                ->booleanNode('durable')->defaultTrue()->end()
76
                                ->booleanNode('auto_delete')->defaultFalse()->end()
77
                            ->end()
78
                        ->end()
79
                    ->end()
80
                ->end()
81
            ->end()
82
        ;
83
84
        return $treeBuilder;
85
    }
86
}
87