Completed
Push — dev-master ( 911a2b...ffe40d )
by Karol
03:14
created

RootNodeFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Pgs\HashIdBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
8
class RootNodeFactory
9
{
10
    public static function create(TreeBuilder $treeBuilder, string $nodeName): NodeDefinition
11
    {
12
        return self::isSymfonyConfigGt41($treeBuilder) ?
13
            $treeBuilder->getRootNode() :
14
            /* @scrutinizer ignore-deprecated */
15
            $treeBuilder->root($nodeName);
16
    }
17
18
    public static function isSymfonyConfigGt41(TreeBuilder $treeBuilder)
19
    {
20
        return method_exists($treeBuilder, 'getRootNode');
21
    }
22
}
23