Failed Conditions
Push — develop ( bf7046...18e86d )
by Maxime
18:38
created

VcsDefinition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 74
ccs 35
cts 35
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getChildren() 0 7 1
A getCredentialsNodes() 0 21 1
A getOptionsNodes() 0 16 1
1
<?php
2
3
/*
4
 * This file is part of Rocketeer
5
 *
6
 * (c) Maxime Fabre <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 */
12
13
namespace Rocketeer\Services\Config\Definition;
14
15
use Symfony\Component\Config\Definition\TreeBuilder\NodeBuilder;
16
17
/**
18
 * Configuration schema for the VCS node.
19
 */
20
class VcsDefinition extends AbstractDefinition
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $name = 'vcs';
26
27
    /**
28
     * @var string
29
     */
30
    protected $description = 'The configuration of your repository';
31
32
    /**
33
     * @param NodeBuilder $node
34
     *
35
     * @return NodeBuilder
36
     */
37 21
    protected function getChildren(NodeBuilder $node)
38
    {
39 21
        $node = $this->getCredentialsNodes($node);
40 21
        $node = $this->getOptionsNodes($node);
41
42 21
        return $node;
43
    }
44
45
    /**
46
     * @param NodeBuilder $node
47
     *
48
     * @return NodeBuilder
49
     */
50 21
    protected function getCredentialsNodes(NodeBuilder $node)
51
    {
52
        return $node
53 21
            ->enumNode('vcs')
54 21
                ->info('The VCS used')
55 21
                ->values(['git', 'svn', 'hg'])
56 21
                ->isRequired()
57 21
                ->defaultValue('git')
58 21
            ->end()
59 21
            ->scalarNode('repository')
60 21
                ->info('The SSH/HTTPS address to your repository')
61 21
                ->example('https://github.com/vendor/website.git')
62 21
                ->defaultValue($this->value('vcs.repository'))
63 21
            ->end()
64 21
            ->scalarNode('username')
65 21
                ->defaultValue($this->value('vcs.username'))
66 21
            ->end()
67 21
            ->scalarNode('password')
68 21
                ->defaultValue($this->value('vcs.password'))
69 21
            ->end();
70
    }
71
72
    /**
73
     * @param NodeBuilder $node
74
     *
75
     * @return NodeBuilder
76
     */
77 21
    protected function getOptionsNodes(NodeBuilder $node)
78
    {
79
        return $node
80 21
            ->scalarNode('branch')
81 21
                ->info('The branch to deploy')
82 21
                ->defaultValue('master')
83 21
            ->end()
84 21
            ->scalarNode('shallow')
85 21
                ->info("Whether your VCS should do a \"shallow\" clone of the repository or not - this means a clone with just the latest state of your application (no history).\nIf you're having problems cloning, try setting this to false")
86 21
                ->defaultTrue()
87 21
            ->end()
88 21
            ->scalarNode('submodules')
89 21
                ->info("Recursively pull in submodules.\nWorks only with Git")
90 21
                ->defaultTrue()
91 21
            ->end();
92
    }
93
}
94