Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

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