Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 60
ccs 34
cts 34
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B getConfigTreeBuilder() 0 33 1
1
<?php
2
3
namespace Gendoria\CommandQueueDoctrineDriverBundle\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
     * Master configuration key.
17
     *
18
     * @var string
19
     */
20
    private $alias;
21
22
    /**
23
     * Class constructor.
24
     *
25
     * @param string $alias
26
     */
27 1
    public function __construct($alias)
28
    {
29 1
        $this->alias = $alias;
30 1
    }
31
32
    /**
33
     * Get config tree builder instance.
34
     *
35
     * {@inheritdoc}
36
     *
37
     * @return TreeBuilder
38
     */
39 1
    public function getConfigTreeBuilder()
40 1
    {
41 1
        $treeBuilder = new TreeBuilder();
42 1
        $rootNode = $treeBuilder->root($this->alias);
43 1
        $rootNode->children()
44 1
            ->arrayNode('drivers')
45 1
                ->prototype('array')
46 1
                    ->children()
47 1
                        ->scalarNode('connection')
48 1
                            ->cannotBeEmpty()
49 1
                            ->isRequired()
50 1
                            ->defaultValue('default')
51 1
                        ->end()
52 1
                        ->scalarNode('serializer')
53 1
                            ->cannotBeEmpty()
54 1
                            ->isRequired()
55 1
                            ->validate()
56 1
                                ->ifTrue(function($v) {
57 1
                                    return strpos($v, '@') !== 0;
58 1
                                })
59 1
                                ->thenInvalid('Serializer has to be in form "@service.id"')
60 1
                            ->end()
61 1
                        ->end()
62 1
                        ->scalarNode('table_name')
63 1
                            ->defaultValue('cmq')
64 1
                        ->end()
65 1
                    ->end()
66 1
                ->end()
67 1
            ->end()
68 1
        ->end();
69
70 1
        return $treeBuilder;
71
    }
72
}
73