Completed
Push — master ( 5256c9...78c262 )
by WEBEWEB
01:56
created

ConfigurationHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getRootNode() 0 11 2
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2019 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\CoreBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
16
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
17
18
/**
19
 * Configuration helper.
20
 *
21
 * @author webeweb <https://github.com/webeweb/>
22
 * @package WBW\Bundle\CoreBundle\DependencyInjection
23
 */
24
class ConfigurationHelper {
25
26
    /**
27
     * Get the root node.
28
     *
29
     * @param TreeBuilder $treeBuilder The tree builder.
30
     * @param string $nodeName The node name.
31
     * @return ArrayNodeDefinition|NodeDefinition Returns the root node.
32
     */
33
    public static function getRootNode(TreeBuilder $treeBuilder, $nodeName) {
34
35
        $method = "getRootNode";
36
        if (true === method_exists($treeBuilder, $method)) {
37
            return $treeBuilder->$method();
38
        } else {
39
            $method = "root";
40
        }
41
42
        return $treeBuilder->$method($nodeName);
43
    }
44
}
45