Completed
Pull Request — master (#6)
by Pierre
31:33 queued 11:19
created

PantherConfiguration   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 8
eloc 46
c 2
b 0
f 0
dl 0
loc 85
ccs 16
cts 18
cp 0.8889
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A addOptionsNode() 0 20 2
A addKernelOptionsNode() 0 20 2
A addManagerOptionsNode() 0 20 2
A getConfigTreeBuilder() 0 14 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Robertfausk\Behat\PantherExtension\ServiceContainer;
5
6
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\ConfigurationInterface;
9
10
/**
11
 * @author Robert Freigang <[email protected]>
12
 */
13
class PantherConfiguration implements ConfigurationInterface
14
{
15
    /**
16
     * @inheritDoc
17
     */
18 3
    public function getConfigTreeBuilder()
19
    {
20 3
        $treeBuilder = new TreeBuilder('panther');
21 3
        if (\method_exists($treeBuilder, 'getRootNode')) {
22
            $root = $treeBuilder->getRootNode();
23
        } else {
24 3
            $root = $treeBuilder->root('panther');
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

24
            $root = /** @scrutinizer ignore-deprecated */ $treeBuilder->root('panther');

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...
25
        }
26
27 3
        $root->append($this->addOptionsNode());
0 ignored issues
show
Bug introduced by
The method append() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

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

27
        $root->/** @scrutinizer ignore-call */ 
28
               append($this->addOptionsNode());
Loading history...
28
        $root->append($this->addKernelOptionsNode());
29 3
        $root->append($this->addManagerOptionsNode());
30
31
        return $treeBuilder;
32 3
    }
33
34 3
    public function addOptionsNode(): ArrayNodeDefinition
35
    {
36 3
        $treeBuilder = new TreeBuilder('options');
37
38
        if (\method_exists($treeBuilder, 'getRootNode')) {
39 3
            $root = $treeBuilder->getRootNode();
40
        } else {
41
            $root = $treeBuilder->root('options');
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

41
            $root = /** @scrutinizer ignore-deprecated */ $treeBuilder->root('options');

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...
42
        }
43 3
44 3
        $node = $root
45
            ->info(
46 3
                "These are the options passed as first argument to PantherTestCaseTrait::createPantherClient client constructor."
47 3
            )
48 3
            ->ignoreExtraKeys()
0 ignored issues
show
Bug introduced by
The method ignoreExtraKeys() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

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

48
            ->/** @scrutinizer ignore-call */ ignoreExtraKeys()
Loading history...
49
            ->scalarPrototype()
50
            ->end()
51 3
        ;
52
53
        return $node;
54
    }
55
56
    public function addKernelOptionsNode(): ArrayNodeDefinition
57
    {
58
        $treeBuilder = new TreeBuilder('kernel_options');
59
60
        if (\method_exists($treeBuilder, 'getRootNode')) {
61
            $root = $treeBuilder->getRootNode();
62
        } else {
63
            $root = $treeBuilder->root('kernel_options');
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

63
            $root = /** @scrutinizer ignore-deprecated */ $treeBuilder->root('kernel_options');

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...
64
        }
65
66
        $node = $root
67
            ->info(
68
                "These are the options passed as second argument to PantherTestCaseTrait::createPantherClient client constructor."
69
            )
70
            ->ignoreExtraKeys()
71
            ->scalarPrototype()
72
            ->end()
73
        ;
74
75
        return $node;
76
    }
77
78
    public function addManagerOptionsNode(): ArrayNodeDefinition
79
    {
80
        $treeBuilder = new TreeBuilder('manager_options');
81
82
        if (\method_exists($treeBuilder, 'getRootNode')) {
83
            $root = $treeBuilder->getRootNode();
84
        } else {
85
            $root = $treeBuilder->root('manager_options');
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

85
            $root = /** @scrutinizer ignore-deprecated */ $treeBuilder->root('manager_options');

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...
86
        }
87
88
        $node = $root
89
            ->info(
90
                "These are the options passed as third argument to PantherTestCaseTrait::createPantherClient client constructor."
91
            )
92
            ->ignoreExtraKeys()
93
            ->scalarPrototype()
94
            ->end()
95
        ;
96
97
        return $node;
98
    }
99
}
100