Passed
Pull Request — master (#5629)
by Angel Fernando Quiroz
10:06 queued 01:32
created

Configuration   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 25
c 1
b 0
f 0
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 23 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XApi\LrsBundle\DependencyInjection;
6
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\ConfigurationInterface;
9
10
/**
11
 * @author Christian Flothmann <[email protected]>
12
 */
13
final class Configuration implements ConfigurationInterface
14
{
15
    public function getConfigTreeBuilder()
16
    {
17
        $treeBuilder = new TreeBuilder();
18
19
        $treeBuilder
20
            ->root('xapi_lrs')
21
            ->beforeNormalization()
22
            ->ifTrue(function ($v) {
23
                return isset($v['type']) && \in_array($v['type'], ['mongodb', 'orm']) && !isset($v['object_manager_service']);
24
            })
25
            ->thenInvalid('You need to configure the object manager service when the repository type is "mongodb" or orm".')
26
            ->end()
27
            ->children()
28
            ->enumNode('type')
29
            ->isRequired()
30
            ->values(['in_memory', 'mongodb', 'orm'])
31
            ->end()
32
            ->scalarNode('object_manager_service')->end()
33
            ->end()
34
            ->end()
35
        ;
36
37
        return $treeBuilder;
38
    }
39
}
40