Passed
Push — main ( b13b1c...30676d )
by Emlyn
12:24
created

Release::setLinkName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * @category Library
4
 * @license MIT http://opensource.org/licenses/MIT
5
 * @link https://github.com/emlynwest/changelog
6
 */
7
8
namespace ChangeLog;
9
10
use DateTime;
11
12
/**
13
 * Contains information about an individual release.
14
 */
15
class Release
16
{
17
18
	/**
19
	 * @var string
20
	 */
21
	protected $name;
22
23
	/**
24
	 * @var bool
25
	 */
26
	protected $yanked = false;
27
28
	/**
29
	 * @var string
30
	 */
31
	protected $link;
32
33
	/**
34
	 * @var DateTime
35
	 */
36
	protected $date;
37
38
	/**
39
	 * List of all changes in this release indexed by change type.
40
	 *
41
	 * @var array
42
	 */
43
	protected $changes = [];
44
45
	/**
46
	 * Optional link name.
47
	 *
48
	 * @var string
49
	 */
50
	protected $linkName;
51
52
	/**
53
	 * @param string $name
54
	 */
55 34
	public function __construct($name = null)
56
	{
57 34
		$this->setName($name);
58
	}
59
60
	/**
61
	 * @return string
62
	 */
63 28
	public function getName()
64
	{
65 28
		return $this->name;
66
	}
67
68
	/**
69
	 * @param string $name
70
	 */
71 34
	public function setName($name)
72
	{
73 34
		$this->name = $name;
74
	}
75
76
	/**
77
	 * @return boolean
78
	 */
79 6
	public function isYanked()
80
	{
81 6
		return $this->yanked;
82
	}
83
84
	/**
85
	 * @param boolean $yanked
86
	 */
87 3
	public function setYanked($yanked)
88
	{
89 3
		$this->yanked = $yanked;
90
	}
91
92
	/**
93
	 * @return string
94
	 */
95 18
	public function getLink()
96
	{
97 18
		return $this->link;
98
	}
99
100
	/**
101
	 * @param string $link
102
	 */
103 15
	public function setLink($link)
104
	{
105 15
		$this->link = $link;
106
	}
107
108
	/**
109
	 * Adds a change to the release.
110
	 *
111
	 * @param string $type
112
	 * @param string $message
113
	 */
114 3
	public function addChange($type, $message)
115
	{
116 3
		$this->changes[$type][] = $message;
117
	}
118
119
	/**
120
	 * Sets all the changes for the given type
121
	 *
122
	 * @param string   $type
123
	 * @param string[] $changes
124
	 */
125 1
	public function setChanges($type, $changes)
126
	{
127 1
		$this->changes[$type] = $changes;
128
	}
129
130
	/**
131
	 * Returns all changes for the given type or null if there are no changes.
132
	 *
133
	 * @param string $type
134
	 *
135
	 * @return string[]|null
136
	 */
137 1
	public function getChanges($type)
138
	{
139 1
		if ( ! isset($this->changes[$type]))
140
		{
141 1
			return null;
142
		}
143
144 1
		return $this->changes[$type];
145
	}
146
147
	/**
148
	 * Returns all changes in the release indexed by type
149
	 *
150
	 * @return array
151
	 */
152 16
	public function getAllChanges()
153
	{
154 16
		return $this->changes;
155
	}
156
157
	/**
158
	 * Sets all the changes for the release, should be indexed by change type.
159
	 *
160
	 * @param string[] $changes
161
	 */
162 19
	public function setAllChanges($changes)
163
	{
164 19
		$this->changes = $changes;
165
	}
166
167
	/**
168
	 * @return DateTime
169
	 */
170 16
	public function getDate()
171
	{
172 16
		return $this->date;
173
	}
174
175
	/**
176
	 * @param DateTime $date
177
	 */
178 15
	public function setDate(DateTime $date)
179
	{
180 15
		$this->date = $date;
181
	}
182
183
	/**
184
	 * @return string
185
	 */
186 15
	public function getLinkName()
187
	{
188 15
		return $this->linkName;
189
	}
190
191
	/**
192
	 * @param string $linkName
193
	 */
194 13
	public function setLinkName($linkName)
195
	{
196 13
		$this->linkName = $linkName;
197
	}
198
199
}
200