Completed
Push — master ( 512f96...569420 )
by Peter
04:49
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 25
ccs 0
cts 25
cp 0
rs 8.8571
cc 1
eloc 23
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2016, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Bundle\DateBundle\DependencyInjection;
11
12
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
13
use Symfony\Component\Config\Definition\ConfigurationInterface;
14
15
class Configuration implements ConfigurationInterface
16
{
17
    /**
18
     * Config tree builder.
19
     *
20
     * Example config:
21
     *
22
     * gps_lab_date:
23
     *     time_zone: 'Europe/Moscow'
24
     *     cookie:
25
     *         used: true
26
     *         name: '_time_zone_name'
27
     *         offset: '_time_zone_offset'
28
     *
29
     * @return TreeBuilder
30
     */
31
    public function getConfigTreeBuilder()
32
    {
33
        return (new TreeBuilder())
34
            ->root('gps_lab_date')
35
            ->addDefaultsIfNotSet()
36
            ->children()
37
                ->scalarNode('time_zone')
38
                ->end()
39
                ->arrayNode('cookie')
40
                    ->children()
41
                        ->scalarNode('used')
42
                            ->defaultValue(true)
43
                        ->end()
44
                        ->scalarNode('name')
45
                            ->cannotBeEmpty()
46
                            ->defaultValue('_time_zone_name')
47
                        ->end()
48
                        ->scalarNode('offset')
49
                            ->cannotBeEmpty()
50
                            ->defaultValue('_time_zone_offset')
51
                        ->end()
52
                    ->end()
53
                ->end()
54
            ->end();
55
    }
56
}
57