Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2.0145

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 14
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 20
ccs 11
cts 13
cp 0.8462
crap 2.0145
rs 9.7998
1
<?php declare(strict_types=1);
2
3
namespace Karser\Recaptcha3Bundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
class Configuration implements ConfigurationInterface
9
{
10 7
    public function getConfigTreeBuilder()
11
    {
12 7
        if (method_exists(TreeBuilder::class, 'getRootNode')) {
13 7
            $treeBuilder = new TreeBuilder('karser_recaptcha3');
14 7
            $rootNode = $treeBuilder->getRootNode();
15
        } else {
16
            // BC layer for symfony/config 4.1 and older
17
            $treeBuilder = new TreeBuilder();
18
            $rootNode = $treeBuilder->root('karser_recaptcha3', 'array');
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

18
            $rootNode = /** @scrutinizer ignore-deprecated */ $treeBuilder->root('karser_recaptcha3', 'array');

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...
19
        }
20
        $rootNode
21 7
            ->children()
22 7
                ->scalarNode('site_key')->isRequired()->end()
23 7
                ->scalarNode('secret_key')->isRequired()->end()
24 7
                ->floatNode('score_threshold')->min(0.0)->max(1.0)->defaultValue(0.5)->end()
25 7
                ->booleanNode('enabled')->defaultTrue()->end()
26 7
            ->end()
27
        ;
28
29 7
        return $treeBuilder;
30
    }
31
}
32