Completed
Push — master ( ae4a40...cd3ab6 )
by Tristan
13:24 queued 09:52
created

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 45 1
1
<?php
2
3
/**
4
 * MyPoseo API Bundle
5
 *
6
 * @author Tristan Bessoussa <[email protected]>
7
 */
8
9
namespace Tristanbes\MyPoseoBundle\DependencyInjection;
10
11
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
12
use Symfony\Component\Config\Definition\ConfigurationInterface;
13
14
/**
15
 * This is the class that validates and merges configuration from your app/config files
16
 *
17
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
18
 */
19
class Configuration implements ConfigurationInterface
20
{
21
    /**
22
     * {@inheritDoc}
23
     */
24
    public function getConfigTreeBuilder()
25
    {
26
        $treeBuilder = new TreeBuilder();
27
        $rootNode = $treeBuilder->root('my_poseo');
28
29
        $rootNode
30
            ->children()
31
                ->arrayNode('api')
32
                    ->children()
33
                        ->scalarNode('search_class')
34
                            ->defaultValue('Tristanbes\MyPoseoBundle\Api\Search')
35
                            ->info('Defines the class for the service, useful for tests to avoid real api calls')
36
                        ->end()
37
                        ->scalarNode('cache_service_id')
38
                            ->info('Defines the service id of the cache that will be used')
39
                            ->defaultValue(null)
40
                        ->end()
41
                        ->scalarNode('http_client')
42
                            ->info('service http used to make requests, see php-http, if null, tries autodiscovery plugin')
43
                        ->end()
44
                        ->scalarNode('key')
45
                            ->isRequired()
46
                            ->info('The service is not free. You must provide an API Key which can be found on : http://account.myposeo.com/account/configuration/api')
47
                        ->end()
48
                        ->arrayNode('type')
49
                            ->prototype('array')
50
                            ->children()
51
                                ->scalarNode('base_url')
52
                                    ->isRequired()
53
                                    ->defaultValue('http://api.myposeo.com/1.1/m/api/')
54
                                    ->info('The API version you want to use')
55
                                ->end()
56
                                ->booleanNode('cache')
57
                                    ->defaultTrue()
58
                                ->end()
59
                                ->scalarNode('cache_ttl')->end()
60
                            ->end()
61
                        ->end()
62
                    ->end()
63
                ->end()
64
            ->end()
65
        ;
66
67
        return $treeBuilder;
68
    }
69
}
70