Passed
Push — features/scrutinizer_conf ( cf2d4a...45dfb6 )
by Nicolas
01:09
created

ApplicationConfiguration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 19
nc 1
nop 0
dl 0
loc 25
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: nicolas
5
 * Date: 18/02/17
6
 * Time: 07:26
7
 */
8
9
namespace Devgiants\Configuration;
10
11
12
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Config...ion\Builder\TreeBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Symfony\Component\Config\Definition\ConfigurationInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Config...\ConfigurationInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
15
class ApplicationConfiguration implements ConfigurationInterface
16
{
17
    const ROOT_NODE = 'configuration';
18
    const NODE_NAME = 'name';
19
    const NODE_DEFAULT_VALUE = 'default_value';
20
21
    const HOST = [
22
        self::NODE_NAME => 'host',
23
        self::NODE_DEFAULT_VALUE => '192.168.1.1'
24
    ];
25
26
	const USER = [
27
		self::NODE_NAME => 'user',
28
		self::NODE_DEFAULT_VALUE => 'admin'
29
	];
30
31
    const PASSWORD = "password";
32
33
34
    public function getConfigTreeBuilder()
35
    {
36
        $treeBuilder = new TreeBuilder();
37
        $rootNode = $treeBuilder->root(static::ROOT_NODE);
38
39
        // add node definitions to the root of the tree
40
        $rootNode
41
            ->children()
42
                ->scalarNode(static::HOST[static::NODE_NAME])
43
                    ->defaultValue(static::HOST[static::NODE_DEFAULT_VALUE])
44
                    ->info('Contains the Livebox IP address or local DNS name. Default to 192.168.1.1')
45
                ->end()
46
		        ->scalarNode(static::USER[static::NODE_NAME])
47
			        ->defaultValue(static::USER[static::NODE_DEFAULT_VALUE])
48
			        ->info('Contains user for connecting. Default to admin')
49
		        ->end()
50
		        ->scalarNode(static::PASSWORD)
51
			        ->info('Contains password for connecting')
52
			        ->isRequired()
53
			        ->cannotBeEmpty()
54
		        ->end()
55
            ->end()
56
        ;
57
58
        return $treeBuilder;
59
    }
60
}