Completed
Push — master ( 6cec30...bddb48 )
by nicolas
11s
created

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 26 1
1
<?php
2
3
namespace Dekalee\AdbackAnalyticsBundle\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/configuration.html}
12
 */
13
class Configuration implements ConfigurationInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function getConfigTreeBuilder()
19
    {
20
        $treeBuilder = new TreeBuilder();
21
        $rootNode = $treeBuilder->root('dekalee_adback_analytics');
22
23
        $supportedCacheTypes = ['redis', 'doctrine', 'config_file'];
24
25
        $rootNode->children()
26
            ->scalarNode('access_token')->isRequired()->end()
27
            ->scalarNode('api_url')->defaultValue('https://adback.co/api')->end()
28
            ->scalarNode('script_url')->defaultValue('script/me')->end()
29
            ->scalarNode('cache_type')
30
                ->validate()
31
                    ->ifNotInArray($supportedCacheTypes)
32
                    ->thenInvalid('The driver %s is not supported. Please choose one of '.json_encode($supportedCacheTypes))
33
                ->end()
34
                ->cannotBeOverwritten()
35
                ->cannotBeEmpty()
36
                ->defaultValue('redis')
37
            ->end()
38
            ->scalarNode('cache_service')->defaultValue('redis')->end()
39
            ->scalarNode('entity_manager')->defaultValue('doctrine.orm.entity_manager')->end()
40
        ->end();
41
42
        return $treeBuilder;
43
    }
44
}
45