TreeConfigBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A root() 0 6 2
A getNode() 0 4 1
1
<?php
2
/*
3
 * This file is part of the Borobudur-Config package.
4
 *
5
 * (c) Hexacodelabs <http://hexacodelabs.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Borobudur\Config\Definition\Builder;
12
13
use Borobudur\Config\Definition\AbstractNumericNode;
14
use Borobudur\Config\Definition\NodeInterface;
15
use Borobudur\Config\Definition\PrototypeNodeInterface;
16
17
/**
18
 * @author      Iqbal Maulana <[email protected]>
19
 * @created     8/10/15
20
 */
21
class TreeConfigBuilder
22
{
23
    /**
24
     * @var ArrayDefinition
25
     */
26
    protected $root;
27
28
    /**
29
     * Create root node.
30
     *
31
     * @param string                     $name
32
     * @param string                     $type
33
     * @param NodeDefinitionBuilder|null $builder
34
     *
35
     * @return ArrayDefinition|EnumDefinition|AbstractNumericNode|NodeDefinitionInterface
36
     */
37
    public function root($name, $type = 'array', NodeDefinitionBuilder $builder = null)
38
    {
39
        $builder = $builder ?: new NodeDefinitionBuilder();
40
41
        return $this->root = $builder->node($name, $type);
42
    }
43
44
    /**
45
     * Get tree node.
46
     *
47
     * @return NodeInterface|PrototypeNodeInterface
48
     */
49
    public function getNode()
50
    {
51
        return $this->root->getNode();
52
    }
53
}
54