Completed
Push — master ( 34b6bb...b66966 )
by Benoit
13s queued 11s
created

Configuration   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 27
c 1
b 1
f 0
dl 0
loc 47
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 29 1
A __construct() 0 3 1
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