Completed
Push — 2.0 ( 0c16d7...3ed48a )
by Peter
04:05
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 26
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 30
ccs 26
cts 26
cp 1
rs 8.8571
cc 1
eloc 27
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/GPL-3.0 GPL v3
8
 */
9
namespace AnimeDb\Bundle\AniDbBrowserBundle\DependencyInjection;
10
11
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
12
use Symfony\Component\Config\Definition\ConfigurationInterface;
13
14
class Configuration implements ConfigurationInterface
15
{
16
    /**
17
     * Config tree builder.
18
     *
19
     * Example config:
20
     *
21
     * anime_db_ani_db_browser:
22
     *     client: 'cache'
23
     *     app:
24
     *         version: 2
25
     *         client: 'animedbplugin'
26
     *         code: 'api-team-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
27
     *
28
     * @return TreeBuilder
29
     */
30 11
    public function getConfigTreeBuilder()
31
    {
32 11
        $tree_builder = new TreeBuilder();
33
        $tree_builder
34 11
            ->root('anime_db_ani_db_browser')
35 11
                ->children()
36 11
                    ->scalarNode('client')
37 11
                        ->cannotBeEmpty()
38 11
                        ->defaultValue('cache')
39 11
                    ->end()
40 11
                    ->arrayNode('app')
41 11
                        ->isRequired()
42 11
                        ->children()
43 11
                            ->integerNode('version')
44 11
                                ->isRequired()
45 11
                            ->end()
46 11
                            ->scalarNode('client')
47 11
                                ->cannotBeEmpty()
48 11
                                ->isRequired()
49 11
                            ->end()
50 11
                            ->scalarNode('code')
51 11
                                ->cannotBeEmpty()
52 11
                                ->isRequired()
53 11
                            ->end()
54 11
                        ->end()
55 11
                    ->end()
56 11
                ->end();
57
58 11
        return $tree_builder;
59
    }
60
}
61