Configuration::getConfigTreeBuilder()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
rs 8.9713
cc 1
eloc 21
nc 1
nop 0
1
<?php
2
/**
3
 * OpenExchangeRates Bundle for Symfony2
4
 *
5
 * @author Gonzalo Míguez ([email protected])
6
 * @since 2014
7
 */
8
9
namespace Mrzard\OpenExchangeRatesBundle\DependencyInjection;
10
11
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
12
use Symfony\Component\Config\Definition\ConfigurationInterface;
13
14
/**
15
 * Class Configuration
16
 * This is the class that validates and merges configuration from your app/config files
17
 *
18
 * @package Mrzard\OpenExchangeRatesBundle\DependencyInjection
19
 */
20
class Configuration implements ConfigurationInterface
21
{
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function getConfigTreeBuilder()
26
    {
27
        $treeBuilder = new TreeBuilder();
28
        $rootNode = $treeBuilder->root('open_exchange_rates');
29
        $rootNode
30
            ->children()
31
                ->scalarNode('api_id')
32
                    ->cannotBeEmpty()
33
                    ->isRequired()
34
                ->end()
35
                ->arrayNode('api_configuration')
36
                    ->addDefaultsIfNotSet()
37
                    ->children()
38
                        ->scalarNode('https')
39
                            ->defaultValue(false)
40
                        ->end()
41
                        ->scalarNode('base_currency')
42
                            ->defaultValue('USD')
43
                        ->end()
44
                    ->end()
45
            ->end();
46
47
        return $treeBuilder;
48
    }
49
}
50