Definition::addMigrationsNode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 14
rs 9.4286
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
/*
4
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
 *
16
 * This software consists of voluntary contributions made by many individuals
17
 * and is licensed under the MIT license. For more information, see
18
 * <http://www.doctrine-project.org>.
19
 */
20
21
namespace Baleen\Cli\Config;
22
23
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
24
use Symfony\Component\Config\Definition\ConfigurationInterface;
25
26
/**
27
 * Class Definition.
28
 *
29
 * @author Gabriel Somoza <[email protected]>
30
 */
31
class Definition implements ConfigurationInterface
32
{
33
    /**
34
     * @inheritdoc
35
     */
36
    public function getConfigTreeBuilder()
37
    {
38
        $builder = new TreeBuilder();
39
        $root = $builder->root('baleen');
40
        $root->children()
41
            ->arrayNode('providers')
42
                ->isRequired()
43
                ->requiresAtLeastOneElement()
44
                ->useAttributeAsKey('name')
45
                ->prototype('scalar')->end()
46
            ->end()
47
            ->arrayNode('plugins')
48
                ->treatNullLike([])
49
                ->useAttributeAsKey('name')
50
                ->prototype('scalar')->end()
51
            ->end()
52
            ->append($this->addMigrationsNode())
53
            ->append($this->addStorageNode())
54
        ->end();
55
56
        return $builder;
57
    }
58
59
    /**
60
     * addMigrationsNode.
61
     *
62
     * @return \Symfony\Component\Config\Definition\Builder\NodeDefinition
63
     */
64
    protected function addMigrationsNode()
65
    {
66
        $builder = new TreeBuilder();
67
        $node = $builder->root('migrations');
68
69
        $node->isRequired()
70
            ->children()
71
                ->scalarNode('directory')->defaultValue('migrations')->end()
72
                ->scalarNode('namespace')->defaultValue('Migrations')->end()
73
            ->end()
74
        ->end();
75
76
        return $node;
77
    }
78
79
    /**
80
     * addStorageNode.
81
     *
82
     * @return \Symfony\Component\Config\Definition\Builder\NodeDefinition
83
     */
84
    protected function addStorageNode()
85
    {
86
        $builder = new TreeBuilder();
87
        $node = $builder->root('storage');
88
89
        $node->isRequired()
90
            ->children()
91
                ->scalarNode('file')->defaultValue('.baleen_versions')->end()
92
            ->end()
93
        ->end();
94
95
        return $node;
96
    }
97
}
98