Completed
Push — master ( 13d7c7...d0a2a1 )
by
unknown
01:41
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 2.0005

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 19
cts 20
cp 0.95
rs 9.44
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0005
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('happyr_google_analytics');
19
        // Keep compatibility with symfony/config < 4.2
20 1
        if (!method_exists($treeBuilder, 'getRootNode')) {
21
            $root = $treeBuilder->root('happyr_google_analytics');
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\Config...der\TreeBuilder::root() has been deprecated with message: since Symfony 4.3, pass the root name to the constructor instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
22
        } else {
23 1
            $root = $treeBuilder->getRootNode();
24
        }
25
26
        $root
27 1
            ->children()
28 1
            ->booleanNode('enabled')->defaultTrue()->info('If disabled we will not send any data')->end()
29 1
            ->scalarNode('version')->cannotBeEmpty()->defaultValue(1)->info('The version of the Measurement Protocol')->end()
30 1
            ->scalarNode('tracking_id')->isRequired()->cannotBeEmpty()->end()
31
32 1
            ->scalarNode('endpoint')->defaultValue('http://www.google-analytics.com/collect')->cannotBeEmpty()->end()
33 1
            ->scalarNode('http_client')->defaultValue('httplug.client')->end()
34 1
            ->scalarNode('http_message_factory')->defaultValue('httplug.message_factory')->end()
35
36 1
            ->arrayNode('fetching')->addDefaultsIfNotSet()->children()
37 1
                ->integerNode('view_id')->defaultNull()->info('The google analytics view id. This is not the same as the tracking code.')->end()
38 1
                ->scalarNode('cache_service')->defaultNull()->end()
39 1
                ->integerNode('cache_lifetime')->defaultValue(3600)->end()
40 1
                ->scalarNode('client_service')->defaultNull()->end()
41 1
            ->end()
42 1
            ->end()->end();
43
44 1
        return $treeBuilder;
45
    }
46
}
47