FetchCommand   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 98
ccs 14
cts 14
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getCommandLine() 0 13 3
A getRemote() 0 3 1
A getTags() 0 3 1
A getTagsArgument() 0 7 3
A setRemote() 0 3 1
A setTags() 0 3 1
1
<?php
2
3
/**
4
 * Moodle component manager.
5
 *
6
 * @author Luke Carrier <[email protected]>
7
 * @copyright 2016 Luke Carrier
8
 * @license GPL-3.0+
9
 */
10
11
namespace ComponentManager\VersionControl\Git\Command;
12
13
/**
14
 * Fetch references from a remote.
15
 */
16
class FetchCommand implements Command {
17
    /**
18
     * The remote name.
19
     *
20
     * @var string|null
21
     */
22
    protected $remote;
23
24
    /**
25
     * Include tags?
26
     *
27
     * @var boolean|null
28
     */
29
    protected $tags;
30
31
    /**
32
     * Initialiser.
33
     *
34
     * @param string|null $remote
35
     */
36 2
    public function __construct($remote=null) {
37 2
        $this->remote = $remote;
38 2
    }
39
40
    /**
41
     * @inheritdoc Command
42
     */
43 2
    public function getCommandLine() {
44 2
        $args = ['fetch'];
45
46 2
        if ($tags = $this->getTagsArgument()) {
47 1
            $args[] = $tags;
48
        }
49
50 2
        if ($this->remote !== null) {
51 2
            $args[] = $this->remote;
52
        }
53
54 2
        return $args;
55
    }
56
57
    /**
58
     * Get the remote name.
59
     *
60
     * @return string|null
61
     *
62
     * @codeCoverageIgnore
63
     */
64
    public function getRemote() {
65
        return $this->remote;
66
    }
67
68
    /**
69
     * Is the fetch with tags?
70
     *
71
     * @return boolean|null
72
     *
73
     * @codeCoverageIgnore
74
     */
75
    public function getTags() {
76
        return $this->tags;
77
    }
78
79
    /**
80
     * Get the tags argument.
81
     *
82
     * @return string|null
83
     */
84 2
    protected function getTagsArgument() {
85 2
        if ($this->tags === null) {
86 1
            return null;
87
        }
88
89 1
        return '--' . ($this->tags ? '' : 'no-') . 'tags';
90
    }
91
92
    /**
93
     * Set the remote name.
94
     *
95
     * @param string $remote
96
     *
97
     * @codeCoverageIgnore
98
     */
99
    public function setRemote($remote) {
100
        $this->remote = $remote;
101
    }
102
103
    /**
104
     * Enable or disable tags.
105
     *
106
     * @param boolean|null $tags
107
     *
108
     * @codeCoverageIgnore
109
     */
110
    public function setTags($tags) {
111
        $this->tags = $tags;
112
    }
113
}
114