Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B getConfigTreeBuilder() 0 26 1
1
<?php
2
3
namespace Black\Bundle\EmailBundle\Application\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * Class Configuration
10
 */
11
class Configuration implements ConfigurationInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private $alias;
17
18
    /**
19
     * @param string $alias
20
     */
21
    public function __construct($alias)
22
    {
23
        $this->alias = $alias;
24
    }
25
26
    /**
27
     * {@inheritDoc}
28
     */
29
    public function getConfigTreeBuilder()
30
    {
31
        $treeBuilder = new TreeBuilder();
32
        $rootNode    = $treeBuilder->root($this->alias);
33
34
        $supportedDrivers = ['mongodb', 'orm'];
35
36
        $rootNode
37
            ->children()
38
39
                ->scalarNode('db_driver')
40
                    ->validate()
41
                        ->ifNotInArray($supportedDrivers)
42
                        ->thenInvalid('The database driver %s is not supported. Please choose one of ' . json_encode($supportedDrivers))
43
                    ->end()
44
                ->isRequired()
45
                ->cannotBeOverwritten()
46
                ->cannotBeEmpty()
47
                ->end()
48
49
                ->scalarNode('email_class')->isRequired()->cannotBeEmpty()->end()
50
51
            ->end();
52
53
        return $treeBuilder;
54
    }
55
}
56