Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 83
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 77 2
1
<?php
2
3
namespace Mpclarkson\ResqueBundle\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
    public function getConfigTreeBuilder()
19
    {
20
        $treeBuilder = new TreeBuilder();
21
        $rootNode = $treeBuilder->root('resque');
22
23
        $rootNode
24
            ->addDefaultsIfNotSet()
25
            ->children()
26
                ->scalarNode('vendor_dir')
27
                    ->defaultValue('%kernel.root_dir%/../vendor')
28
                    ->cannotBeEmpty()
29
                    ->info('Set the vendor dir')
30
                ->end()
31
                ->scalarNode('app_include')
32
                    ->defaultValue('%kernel.root_dir%/../var/bootstrap.php.cache')
33
                    ->cannotBeEmpty()
34
                    ->info('Set the APP_INCLUDE for php-resque')
35
                ->end()
36
                ->scalarNode('prefix')
37
                    ->defaultNull()
38
                    ->end()
39
                ->scalarNode('class')
40
                    ->defaultValue('Mpclarkson\ResqueBundle\Resque')
41
                    ->cannotBeEmpty()
42
                    ->info('Set the resque class dir')
43
                ->end()
44
                ->arrayNode('auto_retry')
45
                    ->beforeNormalization()
46
                        ->ifArray()
47
                        ->then(function($var) {
48
                            if (array_key_exists(0, $var)) {
49
                                return [$var];
50
                            }
51
                            return $var;
52
                        })
53
                    ->end()
54
                    ->prototype('array')
55
                        ->prototype('scalar')->end()
56
                    ->end()
57
                    ->info('Set auto retry strategy')
58
                ->end()
59
                ->arrayNode('redis')
60
                    ->info('Redis configuration')
61
                    ->addDefaultsIfNotSet()
62
                    ->children()
63
                        ->scalarNode('host')
64
                            ->defaultValue('localhost')
65
                            ->cannotBeEmpty()
66
                            ->info('The redis hostname')
67
                        ->end()
68
                        ->scalarNode('port')
69
                            ->defaultValue(6379)
70
                            ->cannotBeEmpty()
71
                            ->info('The redis port')
72
                        ->end()
73
                        ->scalarNode('database')
74
                            ->defaultValue(0)
75
                            ->info('The redis database')
76
                        ->end()
77
                    ->end()
78
                ->end()
79
                ->arrayNode('worker')
80
                    ->info('Worker Server configuration')
81
                    ->addDefaultsIfNotSet()
82
                    ->children()
83
                        ->scalarNode('root_dir')
84
                            ->defaultValue('%kernel.root_dir%')
85
                            ->cannotBeEmpty()
86
                            ->info('The root dir of worker registered app')
87
                        ->end()
88
                    ->end()
89
                ->end()
90
            ->end()
91
        ;
92
93
        return $treeBuilder;
94
    }
95
}
96