Completed
Push — master ( b540bf...c163b7 )
by Robert
21:47 queued 10s
created

PantherConfiguration::addManagerOptionsNode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 0
cp 0
rs 9.8666
cc 2
nc 2
nop 0
crap 6
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->children()
28
            ->append($this->addOptionsNode())
29 3
            ->append($this->addKernelOptionsNode())
30
            ->append($this->addManagerOptionsNode())
31
        ->end();
32 3
33
        return $treeBuilder;
34 3
    }
35
36 3
    public function addOptionsNode(): ArrayNodeDefinition
37
    {
38
        $treeBuilder = new TreeBuilder('options');
39 3
40
        if (\method_exists($treeBuilder, 'getRootNode')) {
41
            $root = $treeBuilder->getRootNode();
42
        } else {
43 3
            $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

43
            $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...
44 3
        }
45
46 3
        $node = $root
47 3
            ->info(
48 3
                "These are the options passed as first argument to PantherTestCaseTrait::createPantherClient client constructor."
49
            )
50
            ->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

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

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

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