Completed
Pull Request — master (#5)
by Benjamin
04:57
created

Configuration   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 16 1
A getCacheTree() 0 21 1
1
<?php
2
3
namespace Obblm\Core\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
9
/**
10
 * Class Configuration
11
 */
12
class Configuration implements ConfigurationInterface
13
{
14
    public function getConfigTreeBuilder()
15
    {
16
        $treeBuilder = new TreeBuilder('obblm');
17
        $rootNode = $treeBuilder->getRootNode();
18
        $treeBuilder->getRootNode()
19
                ->children()
20
                    ->scalarNode('upload_directory')
21
                    ->end()
22
                    ->scalarNode('public_cache_directory')
23
                    ->end()
24
                ->end()
25
            ->end()
26
        ;
27
        $this->getCacheTree($rootNode);
28
29
        return $treeBuilder;
30
    }
31
    private function getCacheTree(ArrayNodeDefinition $rootNode)
32
    {
33
        return $rootNode
34
            ->fixXmlConfig('cache')
35
            ->children()
36
                ->arrayNode('caches')
37
                    ->addDefaultsIfNotSet()
38
                    ->children()
39
                        ->arrayNode('rules')
40
                            ->addDefaultsIfNotSet()
41
                            ->children()
42
                                ->scalarNode('adapter')
43
                                    ->isRequired()
44
                                    ->cannotBeEmpty()
45
                                    ->defaultValue('app.cache')
46
                                ->end()
47
                            ->end()
0 ignored issues
show
Bug introduced by
The method end() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
                            ->/** @scrutinizer ignore-call */ end()
Loading history...
48
                        ->end()
49
                    ->end()
50
                ->end()
51
            ->end();
52
    }
53
}
54