Completed
Push — master ( 1688c9...0f5d0d )
by Dmitry
04:58 queued 01:37
created

Configuration::addRootSection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
ccs 17
cts 17
cp 1
rs 9.4285
cc 1
eloc 17
nc 1
nop 1
crap 1
1
<?php
2
3
namespace SymfonyBundles\EventQueueBundle\DependencyInjection;
4
5
use SymfonyBundles\EventQueueBundle\Service;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
9
10
class Configuration implements ConfigurationInterface
11
{
12
13
    /**
14
     * {@inheritdoc}
15
     */
16 3
    public function getConfigTreeBuilder()
17
    {
18 3
        $builder = new TreeBuilder();
19 3
        $rootNode = $builder->root('sb_event_queue');
20
21 3
        $this->addRootSection($rootNode);
22 3
        $this->addClassSection($rootNode);
23
24 3
        return $builder;
25
    }
26
27
    /**
28
     * Adds root node configuration.
29
     *
30
     * @param ArrayNodeDefinition $node
31
     */
32 3
    private function addRootSection(ArrayNodeDefinition $node)
33
    {
34
        $node
35 3
            ->addDefaultsIfNotSet()
36 3
            ->children()
37 3
                ->scalarNode('service_name')
38 3
                    ->defaultValue('event_queue')
39 3
                    ->cannotBeEmpty()
40 3
                ->end()
41 3
                ->scalarNode('default_name')
42 3
                    ->defaultValue('event:default')
43 3
                    ->cannotBeEmpty()
44 3
                ->end()
45 3
                ->scalarNode('storage_path')
46 3
                    ->defaultValue('%kernel.cache_dir%/event-queue-daemon.%s.pid')
47 3
                    ->cannotBeEmpty()
48 3
                ->end()
49 3
            ->end();
50 3
    }
51
52
    /**
53
     * Adds the sb_event_queue.class configuration.
54
     *
55
     * @param ArrayNodeDefinition $node
56
     */
57 3
    private function addClassSection(ArrayNodeDefinition $node)
58
    {
59
        $node
60 3
            ->children()
61 3
                ->arrayNode('class')
62 3
                    ->addDefaultsIfNotSet()
63 3
                    ->children()
64 3
                        ->scalarNode('dispatcher')
65 3
                            ->defaultValue(Service\Dispatcher::class)
66 3
                            ->cannotBeEmpty()
67 3
                        ->end()
68 3
                    ->end()
69 3
                ->end()
70 3
            ->end();
71 3
    }
72
73
}
74