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

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 42
ccs 0
cts 25
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 25 1
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