Completed
Push — master ( 239355...d39289 )
by Matthew
05:26
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 71
Code Lines 66

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 65
CRAP Score 1

Importance

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

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