Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 68
c 1
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 62 1
1
<?php
2
3
namespace Browscap\BrowscapBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * @author Joshua Estes <[email protected]>
10
 */
11
class Configuration implements ConfigurationInterface
12
{
13
    /**
14
     * {@inheritDoc}
15
     */
16
    public function getConfigTreeBuilder()
17
    {
18
        $treeBuilder = new TreeBuilder();
19
        $rootNode = $treeBuilder->root('browscap');
20
21
        $supportedMethods = array(
22
            'URL-wrapper',
23
            'socket',
24
            'cURL',
25
            'local',
26
        );
27
28
        $rootNode
29
            ->children()
30
                ->scalarNode('cache_dir')
31
                    ->defaultValue(null)
32
                ->end()
33
                ->scalarNode('local_file')
34
                    ->defaultValue(null)
35
                ->end()
36
                ->scalarNode('cache_filename')
37
                    ->defaultValue('cache.php')
38
                ->end()
39
                ->scalarNode('ini_filename')
40
                    ->defaultValue('browscap.ini')
41
                ->end()
42
                ->scalarNode('remote_ini_url')
43
                    ->defaultValue('http://browscap.org/stream?q=Full_PHP_BrowsCapINI')
44
                ->end()
45
                ->scalarNode('remote_ver_url')
46
                    ->defaultValue('http://browscap.org/version')
47
                ->end()
48
                ->booleanNode('lowercase')
49
                    ->defaultValue(false)
50
                ->end()
51
                ->booleanNode('silent')
52
                    ->defaultValue(false)
53
                ->end()
54
                ->scalarNode('timeout')
55
                    ->defaultValue(5)
56
                ->end()
57
                ->scalarNode('update_interval')
58
                    ->defaultValue(432000)
59
                ->end()
60
                ->scalarNode('error_interval')
61
                    ->defaultValue(7200)
62
                ->end()
63
                ->booleanNode('do_auto_update')
64
                    ->defaultValue(true)
65
                ->end()
66
                ->scalarNode('update_method')
67
                    ->validate()
68
                        ->ifNotInArray($supportedMethods)
69
                        ->thenInvalid('The method "%s" is not supported. Please choose one of ' . json_encode($supportedMethods))
70
                    ->end()
71
                    ->cannotBeOverwritten()
72
                    ->defaultValue('cURL')
73
                ->end()
74
            ->end();
75
76
        return $treeBuilder;
77
    }
78
}
79