Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 49
Code Lines 45

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 45
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 45
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 49
ccs 45
cts 45
cp 1
crap 1
rs 9.2
1
<?php
2
3
namespace Pyrowman\PheanstalkBundle\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 11
    public function getConfigTreeBuilder()
19
    {
20 11
        $treeBuilder = new TreeBuilder('pheanstalk');
21 11
        $rootNode = $treeBuilder->getRootNode()->children();
22
23
        $rootNode
24 11
            ->arrayNode('profiler')
25 11
                ->addDefaultsIfNotSet()
26 11
                ->children()
27 11
                    ->scalarNode('enabled')->defaultValue('%kernel.debug%')->end()
28 11
                    ->scalarNode('template')->defaultValue('@Pheanstalk/Profiler/pheanstalk.html.twig')->end()
29 11
                ->end()
30 11
            ->end()
31 11
            ->arrayNode('pheanstalks')
32 11
                ->requiresAtLeastOneElement()
33 11
                ->useAttributeAsKey('name')
34 11
                ->prototype('array')
35 11
                    ->children()
36 11
                        ->scalarNode('server')
37 11
                            ->isRequired()
38 11
                            ->cannotBeEmpty()
39 11
                        ->end()
40 11
                        ->scalarNode('port')
41 11
                            ->cannotBeEmpty()
42 11
                            ->defaultValue('5000')
43 11
                        ->end()
44 11
                        ->scalarNode('user')
45 11
                            ->cannotBeEmpty()
46 11
                        ->end()
47 11
                        ->scalarNode('password')
48 11
                            ->cannotBeEmpty()
49 11
                        ->end()
50 11
                        ->scalarNode('timeout')
51 11
                            ->cannotBeEmpty()
52 11
                            ->defaultValue('60')
53 11
                        ->end()
54 11
                        ->booleanNode('default')
55 11
                            ->defaultFalse()
56 11
                        ->end()
57 11
                        ->scalarNode('proxy')
58 11
                            ->cannotBeEmpty()
59 11
                            ->defaultValue('pheanstalk.proxy.default')
60 11
                        ->end()
61 11
                    ->end()
62 11
                ->end()
63 11
            ->end()
64 11
        ->end();
65
66 11
        return $treeBuilder;
67
    }
68
}
69