Failed Conditions
Branch feature/init (0e876c)
by Yo
04:41 queued 01:07
created

StepLoggerConfiguration::getConfigTreeBuilder()   B

Complexity

Conditions 2
Paths 1

Size

Total Lines 26
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 26
c 0
b 0
f 0
ccs 0
cts 23
cp 0
rs 8.8571
cc 2
eloc 18
nc 1
nop 0
crap 6
1
<?php
2
namespace Yoanm\BehatUtilsExtension\ServiceContainer\Configuration;
3
4
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
7
class StepLoggerConfiguration
8
{
9
    /**
10
     * @return NodeDefinition
11
     */
12
    public function getConfigTreeBuilder()
13
    {
14
        $castToBool = function ($value) {
0 ignored issues
show
Unused Code introduced by
$castToBool is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
15
            $filtered = filter_var(
16
                $value,
17
                FILTER_VALIDATE_BOOLEAN,
18
                FILTER_NULL_ON_FAILURE
19
            );
20
21
            return (null === $filtered) ? (bool) $value : $filtered;
22
        };
23
24
        $treeBuilder = new TreeBuilder();
25
        $rootNode = $treeBuilder->root('step_logger');
26
        $rootNode
27
            ->addDefaultsIfNotSet()
28
            ->treatFalseLike(array('enabled' => false))
29
            ->treatNullLike(array('enabled' => false))
30
            ->treatTrueLike(array('enabled' => true))
31
            ->children()
32
                ->booleanNode('enabled')
33
                    ->defaultFalse()
34
        ;
35
36
        return $rootNode;
37
    }
38
}
39