Passed
Pull Request — master (#19)
by
unknown
02:30
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 24
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 29
rs 9.536
1
<?php
2
3
namespace JBen87\ParsleyBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
class Configuration implements ConfigurationInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    private $alias;
14
15
    /**
16
     * @param string $alias
17
     */
18
    public function __construct(string $alias)
19
    {
20
        $this->alias = $alias;
21
    }
22
23
    /**
24
     * @inheritdoc
25
     */
26
    public function getConfigTreeBuilder(): TreeBuilder
27
    {
28
        $treeBuilder = new TreeBuilder($this->alias);
29
30
        $rootNode = $treeBuilder->getRootNode();
31
        $rootNode
32
            ->children()
33
                ->booleanNode('enabled')
34
                    ->defaultTrue()
35
                ->end()
36
                ->scalarNode('trigger_event')
37
                    ->defaultValue('blur')
38
                ->end()
39
                ->arrayNode('date_pattern')
40
                    ->useAttributeAsKey('locale')
41
                    ->scalarPrototype()->end()
42
                ->end()
43
                ->arrayNode('time_pattern')
44
                    ->useAttributeAsKey('locale')
45
                    ->scalarPrototype()->end()
46
                ->end()
47
                ->arrayNode('datetime_pattern')
48
                    ->useAttributeAsKey('locale')
49
                    ->scalarPrototype()->end()
50
                ->end()
51
            ->end()
52
        ;
53
54
        return $treeBuilder;
55
    }
56
}
57