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

StepLoggerConfiguration   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 32
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3
ccs 0
cts 23
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 26 2
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