TreeConfigBuilder::getNode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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