Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 42
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getConfigTreeBuilder() 0 23 1
1
<?php
2
namespace Dkplus\CsrfApiUnprotectionBundle\DependencyInjection;
3
4
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
5
use Symfony\Component\Config\Definition\ConfigurationInterface;
6
7
final class Configuration implements ConfigurationInterface
8
{
9
    /** @var string */
10
    private $treeRootName;
11
12
    /**
13
     * @param string $treeRootName
14
     */
15 11
    public function __construct($treeRootName)
16
    {
17 11
        $this->treeRootName = $treeRootName;
18 11
    }
19
20
    /**
21
     * Generates the configuration tree builder.
22
     *
23
     * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
24
     */
25 10
    public function getConfigTreeBuilder()
26
    {
27 10
        $treeBuilder = new TreeBuilder();
28 10
        $treeBuilder->root($this->treeRootName)
29 10
            ->children()
30 10
            ->arrayNode('rules')
31 10
                ->addDefaultsIfNotSet()
32 10
                ->children()
33 10
                ->arrayNode('match_uri')
34 10
                    ->beforeNormalization()
35 10
                        ->ifString()
36 10
                        ->then(function ($value) {
37 1
                            return [$value];
38 10
                        })
39 10
                    ->end()
40 10
                    ->isRequired()
41 10
                    ->defaultValue(['#^(/app(_[a-zA-Z]*)?.php)?/api/#'])
42 10
                    ->prototype('scalar')->cannotBeEmpty()->end()
43 10
                ->end()
44 10
            ->end();
45
46 10
        return $treeBuilder;
47
    }
48
}
49