Completed
Push — master ( 06f814...f23c49 )
by Tobias
03:33
created

Configuration   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 95.24%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 37
ccs 20
cts 21
cp 0.9524
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 31 2
1
<?php
2
3
namespace Happyr\GoogleAnalyticsBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * This is the class that validates and merges configuration from your app/config files.
10
 */
11
class Configuration implements ConfigurationInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 1
    public function getConfigTreeBuilder()
17
    {
18 1
        $treeBuilder = new TreeBuilder();
0 ignored issues
show
Unused Code introduced by
$treeBuilder 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...
19 1
        $treeBuilder = new TreeBuilder('happyr_google_analytics');
20
        // Keep compatibility with symfony/config < 4.2
21 1
        if (!method_exists($treeBuilder, 'getRootNode')) {
22
            $root = $treeBuilder->root('happyr_google_analytics');
23
        } else {
24 1
            $root = $treeBuilder->getRootNode();
25
        }
26
27
        $root
28 1
            ->children()
29 1
            ->booleanNode('enabled')->defaultTrue()->info('If disabled we will not send any data')->end()
30 1
            ->scalarNode('version')->cannotBeEmpty()->defaultValue(1)->info('The version of the Measurement Protocol')->end()
31 1
            ->scalarNode('tracking_id')->isRequired()->cannotBeEmpty()->end()
32
33 1
            ->scalarNode('endpoint')->defaultValue('http://www.google-analytics.com/collect')->cannotBeEmpty()->end()
34 1
            ->scalarNode('http_client')->defaultValue('httplug.client')->end()
35 1
            ->scalarNode('http_message_factory')->defaultValue('httplug.message_factory')->end()
36
37 1
            ->arrayNode('fetching')->addDefaultsIfNotSet()->children()
38 1
                ->integerNode('view_id')->defaultNull()->info('The google analytics view id. This is not the same as the tracking code.')->end()
39 1
                ->scalarNode('cache_service')->defaultNull()->end()
40 1
                ->integerNode('cache_lifetime')->defaultValue(3600)->end()
41 1
                ->scalarNode('client_service')->defaultNull()->end()
42 1
            ->end()
43 1
            ->end()->end();
44
45 1
        return $treeBuilder;
46
    }
47
}
48