Configuration::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
1
<?php
2
3
namespace Knp\RadBundle\AppBundle;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
class Configuration implements ConfigurationInterface
9
{
10
    private $bundle;
11
    private $treeBuilderFactory;
12
13
    public function __construct(ConfigurableBundleInterface $bundle, TreeBuilderFactory $treeBuilderFactory = null)
14
    {
15
        $this->bundle = $bundle;
16
        $this->treeBuilderFactory = $treeBuilderFactory ?: new TreeBuilderFactory;
17
    }
18
19
    public function getBundle()
20
    {
21
        return $this->bundle;
22
    }
23
24
    public function getConfigTreeBuilder()
25
    {
26
        $treeBuilder = $this->treeBuilderFactory->createTreeBuilder();
27
        $alias       = $this->bundle->getContainerExtension()->getAlias();
28
        $rootNode    = $treeBuilder->root($alias);
29
30
        $this->bundle->buildConfiguration($rootNode);
31
32
        return $treeBuilder;
33
    }
34
}
35