-
Notifications
You must be signed in to change notification settings - Fork 259
/
TreeBuilder.php
90 lines (84 loc) · 3.42 KB
/
TreeBuilder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/*
* (c) Jean-François Lépine <https://twitter.com/Halleck45>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Hal\Application\Config;
/**
* Builds Tree of configuration
*
* @author Jean-François Lépine <https://twitter.com/Halleck45>
*/
class TreeBuilder implements \Hal\Component\Config\TreeBuilderInterface
{
/**
* Get the tree used for the application
*
* @return \Symfony\Component\Config\Definition\NodeInterface
*/
public function getTree() {
$treeBuilder = new \Symfony\Component\Config\Definition\Builder\TreeBuilder();
$rootNode = $treeBuilder->root('phpmetrics');
$rootNode
->children()
->arrayNode('rules')
->useAttributeAsKey('rulename')
->prototype('array')
->children()
->scalarNode('0')->end()
->scalarNode('1')->end()
->scalarNode('2')->end()
->end()
->end()
->end()
->scalarNode('failure')
->defaultValue(null)
->end()
->arrayNode('path')
->addDefaultsIfNotSet()
->children()
->scalarNode('directory')->defaultValue(null)->end()
->scalarNode('exclude')->defaultValue('Tests|tests|Features|features|\.svn|\.git|vendor')->end()
->scalarNode('extensions')->defaultValue('php|inc')->end()
->booleanNode('symlinks')->defaultValue(false)->end()
->end()
->end()
->booleanNode('ignore-errors')->defaultValue(false)->end()
->arrayNode('logging')
->addDefaultsIfNotSet()
->children()
->arrayNode('report')
->children()
->scalarNode('html')->defaultValue(null)->end()
->scalarNode('xml')->defaultValue(null)->end()
->scalarNode('csv')->defaultValue(null)->end()
->scalarNode('json')->defaultValue(null)->end()
->scalarNode('cli')->defaultValue(null)->end()
->end()
->end()
->arrayNode('violations')
->children()
->scalarNode('xml')->defaultValue(null)->end()
->end()
->end()
->arrayNode('chart')
->children()
->scalarNode('bubbles')->defaultValue(null)->end()
->end()
->end()
->end()
->end()
->arrayNode('template')
->addDefaultsIfNotSet()
->children()
->scalarNode('title')->defaultValue('PhpMetrics report')->end()
->booleanNode('offline')->defaultValue(false)->end()
->end()
->end()
->end()
;
return $treeBuilder->buildTree();
}
}