Passed
Push — remove-scrutinizer ( 2823c8 )
by Alexis
37:30 queued 26:48
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 38
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 31
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 38
rs 9.424
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Liip/FunctionalTestBundle
7
 *
8
 * (c) Lukas Kahwe Smith <[email protected]>
9
 *
10
 * This source file is subject to the MIT license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13
14
namespace Liip\FunctionalTestBundle\DependencyInjection;
15
16
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
17
use Symfony\Component\Config\Definition\ConfigurationInterface;
18
19
/**
20
 * This class contains the configuration information for the bundle.
21
 */
22
class Configuration implements ConfigurationInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function getConfigTreeBuilder(): TreeBuilder
28
    {
29
        if (method_exists(TreeBuilder::class, 'getRootNode')) {
30
            $treeBuilder = new TreeBuilder('liip_functional_test');
31
            $rootNode = $treeBuilder->getRootNode();
32
        } else {
33
            // BC layer for symfony/config 4.1 and older
34
            $treeBuilder = new TreeBuilder();
0 ignored issues
show
Bug introduced by
The call to Symfony\Component\Config...eBuilder::__construct() has too few arguments starting with name. ( Ignorable by Annotation )

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

34
            $treeBuilder = /** @scrutinizer ignore-call */ new TreeBuilder();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
35
            $rootNode = $treeBuilder->root('liip_functional_test', 'array');
0 ignored issues
show
Bug introduced by
The method root() does not exist on Symfony\Component\Config...ion\Builder\TreeBuilder. ( Ignorable by Annotation )

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

35
            /** @scrutinizer ignore-call */ 
36
            $rootNode = $treeBuilder->root('liip_functional_test', 'array');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
        }
37
38
        $rootNode
39
            ->children()
40
                ->scalarNode('command_verbosity')->defaultValue('normal')->end()
41
                ->booleanNode('command_decoration')->defaultTrue()->end()
42
                ->arrayNode('query')
43
                    ->addDefaultsIfNotSet()
44
                    ->children()
45
                        ->scalarNode('max_query_count')
46
                            ->defaultNull()
47
                        ->end()
48
                    ->end()
49
                ->end()
50
                ->arrayNode('authentication')
51
                    ->addDefaultsIfNotSet()
52
                    ->children()
53
                        ->scalarNode('username')
54
                            ->defaultValue('')
55
                        ->end()
56
                        ->scalarNode('password')
57
                            ->defaultValue('')
58
                        ->end()
59
                    ->end()
60
                ->end()
61
            ->end()
62
        ;
63
64
        return $treeBuilder;
65
    }
66
}
67