Completed
Branch unittests (5b5894)
by Ruben
02:30
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 19
cts 19
cp 1
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 20
nc 1
nop 0
crap 1
1
<?php
2
3
namespace MovingImage\Bundle\VMProApiBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * Class Configuration.
10
 *
11
 * @author Ruben Knol <[email protected]>
12
 */
13
class Configuration implements ConfigurationInterface
14
{
15
    /**
16
     * @const Which API base URL to use by default.
17
     */
18
    const DEFAULT_API_BASE_URL = 'https://api.video-cdn.net/v1/vms/';
19
20
    /**
21
     * Build the configuration structure for this bundle.
22
     *
23
     * @return TreeBuilder
24
     */
25 12
    public function getConfigTreeBuilder()
26
    {
27 12
        $treeBuilder = new TreeBuilder();
28 12
        $rootNode = $treeBuilder->root('vm_pro_api');
29
30
        $rootNode
31 12
            ->children()
32 12
                ->scalarNode('base_url')
33 12
                    ->defaultValue(self::DEFAULT_API_BASE_URL)
34 12
                ->end()
35 12
                ->integerNode('default_vm_id')
36 12
                    ->defaultValue(0)
37 12
                ->end()
38 12
                ->arrayNode('credentials')
39 12
                    ->isRequired()
40 12
                    ->children()
41 12
                        ->scalarNode('username')->isRequired()->end()
42 12
                        ->scalarNode('password')->isRequired()->end()
43 12
                    ->end()
44 12
                ->end()
45 12
            ->end()
46
        ;
47
48 12
        return $treeBuilder;
49
    }
50
}
51