Passed
Push — issue-20 ( 81b6c3 )
by Benoit
08:32
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

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