Failed Conditions
Pull Request — master (#46)
by
unknown
01:56
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2.0014

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
c 2
b 0
f 0
dl 0
loc 23
ccs 13
cts 14
cp 0.9286
rs 9.7666
cc 2
nc 2
nop 0
crap 2.0014
1
<?php
2
namespace Yoanm\SymfonyJsonRpcHttpServer\DependencyInjection;
3
4
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
5
use Symfony\Component\Config\Definition\ConfigurationInterface;
6
7
class Configuration implements ConfigurationInterface
8
{
9
    const DEFAULT_ENDPOINT = '/json-rpc';
10
11 1
    public function getConfigTreeBuilder()
12
    {
13 1
        $treeBuilder = new TreeBuilder(JsonRpcHttpServerExtension::EXTENSION_IDENTIFIER);
14
15 1
        if (method_exists($treeBuilder, 'getRootNode')) {
16 1
            $rootNode = $treeBuilder->getRootNode();
17
        } else {
18
            // BC layer for symfony/config 4.1 and older
19
            $rootNode = $treeBuilder->root(JsonRpcHttpServerExtension::EXTENSION_IDENTIFIER);
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Component\Config...der\TreeBuilder::root() has been deprecated: since Symfony 4.3, pass the root name to the constructor instead ( Ignorable by Annotation )

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

19
            $rootNode = /** @scrutinizer ignore-deprecated */ $treeBuilder->root(JsonRpcHttpServerExtension::EXTENSION_IDENTIFIER);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
20
        }
21
22
        $rootNode
23 1
            ->addDefaultsIfNotSet()
24 1
            ->children()
25 1
                ->variableNode('endpoint')
26 1
                    ->info('Your custom JSON-RPC http endpoint path')
27 1
                    ->treatNullLike(self::DEFAULT_ENDPOINT)
28 1
                    ->defaultValue(self::DEFAULT_ENDPOINT)
29 1
                ->end()
30 1
            ->end()
31
        ;
32
33 1
        return $treeBuilder;
34
    }
35
}
36