RbacConfigStructure   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 44
dl 0
loc 50
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 48 1
1
<?php
2
3
namespace Potievdev\SlimRbac\Component\Config;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * Rbac configuration structure.
10
 */
11
class RbacConfigStructure implements ConfigurationInterface
12
{
13
    public function getConfigTreeBuilder(): TreeBuilder
14
    {
15
        $treeBuilder = new TreeBuilder('rbac');
16
        $rootNode = $treeBuilder->getRootNode();
17
18
        $rootNode
19
            ->children()
20
                ->arrayNode('database')
21
                    ->children()
22
                        ->enumNode('driver')
23
                            ->values(['pdo_mysql', 'pdo_postgres'])
24
                            ->isRequired()
25
                        ->end()
26
                        ->scalarNode('host')
27
                            ->cannotBeEmpty()
28
                        ->end()
29
                        ->scalarNode('user')
30
                            ->cannotBeEmpty()
31
                        ->end()
32
                        ->scalarNode('password')
33
                            ->cannotBeEmpty()
34
                        ->end()
35
                        ->integerNode('port')
36
                            ->isRequired()
37
                        ->end()
38
                        ->scalarNode('dbname')
39
                            ->cannotBeEmpty()
40
                        ->end()
41
                        ->scalarNode('charset')
42
                            ->cannotBeEmpty()
43
                        ->end()
44
                    ->end()
45
                ->end()
46
                ->arrayNode('userId')
47
                    ->children()
48
                        ->scalarNode('fieldName')
49
                            ->cannotBeEmpty()
50
                        ->end()
51
                        ->enumNode('resourceType')
52
                            ->values(['attribute', 'header', 'cookie'])
53
                            ->isRequired()
54
                        ->end()
55
                    ->end()
56
                ->end()
57
            ->end()
58
        ;
59
60
        return $treeBuilder;
61
    }
62
}