Completed
Push — master ( ff4180...f6540e )
by Yohan
07:27
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.552
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace CalendR\Bridge\Symfony\Bundle\DependencyInjection;
4
5
use CalendR\Period\Day;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
9
class Configuration implements ConfigurationInterface
10
{
11
    public function getConfigTreeBuilder()
12
    {
13
        $builder = new TreeBuilder();
14
        $root    = $builder->root('calendr');
15
16
        $root
17
            ->children()
18
                ->arrayNode('periods')
19
                    ->addDefaultsIfNotSet()
20
                    ->children()
21
                        ->scalarNode('default_first_weekday')
22
                            ->defaultValue(Day::MONDAY)
23
                            ->validate()
24
                                ->ifNotInArray(range(DAY::SUNDAY, DAY::SATURDAY))
25
                                ->thenInvalid('Day must be be between 0 (Sunday) and 6 (Saturday)')
26
                            ->end()
27
                        ->end()
28
                    ->end()
29
                ->end()
30
            ->end();
31
32
        return $builder;
33
    }
34
}
35