GitRepoConnectionSettings   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 162
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 16
lcom 3
cbo 1
dl 0
loc 162
ccs 0
cts 63
cp 0
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A getServerType() 0 4 1
A hasHostName() 0 4 1
A getHostName() 0 4 1
A setHostName() 0 4 1
A hasGroupName() 0 4 1
A getGroupName() 0 4 1
A setGroupName() 0 4 1
A hasRepoName() 0 4 1
A getRepoName() 0 4 1
A setRepoName() 0 4 1
A hasNamedReference() 0 4 1
A getNamedReference() 0 4 1
A setNamedReference() 0 4 1
A getRequiredKeys() 0 4 1
1
<?php
2
3
namespace ConfigToken\ConnectionSettings\Types;
4
5
6
abstract class GitRepoConnectionSettings extends GenericConnectionSettings
7
{
8
    const HOST_NAME = 'host';
9
    const GROUP_NAME = 'group';
10
    const REPO_NAME = 'repo';
11
    const NAMED_REFERENCE = 'version';
12
13
    /**
14
     * @param array|null $parameters
15
     */
16
    public function __construct(array $parameters = null)
17
    {
18
        parent::__construct($parameters);
19
        if (!$this->hasNamedReference()) {
20
            $this->setNamedReference('master');
21
        }
22
    }
23
24
    /**
25
     * Get the file server type identifier corresponding to the client's implementation.
26
     *
27
     * @return string|null If fallback class for all server types.
28
     */
29
    public static function getServerType()
30
    {
31
        return 'git';
32
    }
33
34
    /**
35
     * Check if the host name of the Git repository was set.
36
     *
37
     * @return boolean
38
     */
39
    public function hasHostName()
40
    {
41
        return $this->hasParameter(self::HOST_NAME);
42
    }
43
44
    /**
45
     * Get the host name of the Git repository.
46
     *
47
     * @return string|null
48
     */
49
    public function getHostName()
50
    {
51
        return $this->getParameter(self::HOST_NAME);
52
    }
53
54
    /**
55
     * Set the host name of the Git repository.
56
     *
57
     * @param string $value The new value.
58
     * @return $this
59
     */
60
    public function setHostName($value)
61
    {
62
        return $this->setParameter(self::HOST_NAME, $value);
63
    }
64
65
    /**
66
     * Check if the group name was set.
67
     *
68
     * @return boolean
69
     */
70
    public function hasGroupName()
71
    {
72
        return $this->hasParameter(self::GROUP_NAME);
73
    }
74
75
    /**
76
     * Get the group name.
77
     *
78
     * @return string|null
79
     */
80
    public function getGroupName()
81
    {
82
        return $this->getParameter(self::GROUP_NAME);
83
    }
84
85
    /**
86
     * Set the group name.
87
     *
88
     * @param string $value The new value.
89
     * @return $this
90
     */
91
    public function setGroupName($value)
92
    {
93
        return $this->setParameter(self::GROUP_NAME, $value);
94
    }
95
96
    /**
97
     * Check if the repo name was set.
98
     *
99
     * @return boolean
100
     */
101
    public function hasRepoName()
102
    {
103
        return $this->hasParameter(self::REPO_NAME);
104
    }
105
106
    /**
107
     * Get the repo name.
108
     *
109
     * @return string|null
110
     */
111
    public function getRepoName()
112
    {
113
        return $this->getParameter(self::REPO_NAME);
114
    }
115
116
    /**
117
     * Set the repo name.
118
     *
119
     * @param string $value The new value.
120
     * @return $this
121
     */
122
    public function setRepoName($value)
123
    {
124
        return $this->setParameter(self::REPO_NAME, $value);
125
    }
126
127
    /**
128
     * Check if the named reference (tag or branch) was set.
129
     *
130
     * @return boolean
131
     */
132
    public function hasNamedReference()
133
    {
134
        return $this->hasParameter(self::NAMED_REFERENCE);
135
    }
136
137
    /**
138
     * Get the named reference (tag or branch).
139
     *
140
     * @return string|null
141
     */
142
    public function getNamedReference()
143
    {
144
        return $this->getParameter(self::NAMED_REFERENCE);
145
    }
146
147
    /**
148
     * Set the named reference (tag or branch).
149
     *
150
     * @param string $value The new value.
151
     * @return $this
152
     */
153
    public function setNamedReference($value)
154
    {
155
        return $this->setParameter(self::NAMED_REFERENCE, $value);
156
    }
157
158
    /**
159
     * Get the required keys.
160
     *
161
     * @return array
162
     */
163
    protected static function getRequiredKeys()
164
    {
165
        return array(static::HOST_NAME, static::GROUP_NAME, static::REPO_NAME, static::NAMED_REFERENCE);
166
    }
167
}