GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Labels::getListByMilestone()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * Part of the Joomla Framework Github Package
4
 *
5
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
6
 * @license    GNU General Public License version 2 or later; see LICENSE
7
 */
8
9
namespace Joomla\Github\Package\Issues;
10
11
use Joomla\Github\AbstractPackage;
12
13
/**
14
 * GitHub API Milestones class for the Joomla Framework.
15
 *
16
 * @documentation  http://developer.github.com/v3/issues/labels/
17
 *
18
 * @since  1.0
19
 */
20
class Labels extends AbstractPackage
21
{
22
	/**
23
	 * List all labels for this repository.
24
	 *
25
	 * @param   string  $owner  The name of the owner of the GitHub repository.
26
	 * @param   string  $repo   The name of the GitHub repository.
27
	 *
28
	 * @return  array
29
	 *
30
	 * @since   1.0
31
	 */
32
	public function getList($owner, $repo)
33
	{
34
		// Build the request path.
35
		$path = '/repos/' . $owner . '/' . $repo . '/labels';
36
37
		// Send the request.
38
		return $this->processResponse(
39
			$response = $this->client->get($this->fetchUrl($path))
40
		);
41
	}
42
43
	/**
44
	 * Get a single label.
45
	 *
46
	 * @param   string  $user  The name of the owner of the GitHub repository.
47
	 * @param   string  $repo  The name of the GitHub repository.
48
	 * @param   string  $name  The label name to get.
49
	 *
50
	 * @return  object
51
	 *
52
	 * @since   1.0
53
	 */
54
	public function get($user, $repo, $name)
55
	{
56
		// Build the request path.
57
		$path = '/repos/' . $user . '/' . $repo . '/labels/' . rawurlencode($name);
58
59
		// Send the request.
60
		return $this->processResponse(
61
			$response = $this->client->get($this->fetchUrl($path))
62
		);
63
	}
64
65
	/**
66
	 * Create a label.
67
	 *
68
	 * @param   string  $owner  The name of the owner of the GitHub repository.
69
	 * @param   string  $repo   The name of the GitHub repository.
70
	 * @param   string  $name   The label name.
71
	 * @param   string  $color  The label color.
72
	 *
73
	 * @return  object
74
	 *
75
	 * @since   1.0
76
	 * @throws  \DomainException
77
	 */
78
	public function create($owner, $repo, $name, $color)
79
	{
80
		// Build the request path.
81
		$path = '/repos/' . $owner . '/' . $repo . '/labels';
82
83
		// Build the request data.
84
		$data = json_encode(
85
			array(
86
				'name'  => $name,
87
				'color' => $color,
88
			)
89
		);
90
91
		// Send the request.
92
		return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
93
	}
94
95
	/**
96
	 * Delete a label.
97
	 *
98
	 * @param   string  $owner  The name of the owner of the GitHub repository.
99
	 * @param   string  $repo   The name of the GitHub repository.
100
	 * @param   string  $name   The label name.
101
	 *
102
	 * @return  object
103
	 *
104
	 * @since   1.0
105
	 */
106 View Code Duplication
	public function delete($owner, $repo, $name)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
107
	{
108
		// Build the request path.
109
		$path = '/repos/' . $owner . '/' . $repo . '/labels/' . rawurlencode($name);
110
111
		// Send the request.
112
		return $this->processResponse(
113
			$this->client->delete($this->fetchUrl($path)),
114
			204
115
		);
116
	}
117
118
	/**
119
	 * Update a label.
120
	 *
121
	 * @param   string  $user   The name of the owner of the GitHub repository.
122
	 * @param   string  $repo   The name of the GitHub repository.
123
	 * @param   string  $label  The label name.
124
	 * @param   string  $name   The new label name.
125
	 * @param   string  $color  The new label color.
126
	 *
127
	 * @return  object
128
	 *
129
	 * @since   1.0
130
	 */
131
	public function update($user, $repo, $label, $name, $color)
132
	{
133
		// Build the request path.
134
		$path = '/repos/' . $user . '/' . $repo . '/labels/' . $label;
135
136
		// Build the request data.
137
		$data = json_encode(
138
			array(
139
				'name'  => $name,
140
				'color' => $color,
141
			)
142
		);
143
144
		// Send the request.
145
		return $this->processResponse(
146
			$this->client->patch($this->fetchUrl($path), $data)
147
		);
148
	}
149
150
	/**
151
	 * List labels on an issue.
152
	 *
153
	 * @param   string   $owner   The name of the owner of the GitHub repository.
154
	 * @param   string   $repo    The name of the GitHub repository.
155
	 * @param   integer  $number  The issue number.
156
	 *
157
	 * @return  object
158
	 *
159
	 * @since   1.0
160
	 */
161
	public function getListByIssue($owner, $repo, $number)
162
	{
163
		// Build the request path.
164
		$path = '/repos/' . $owner . '/' . $repo . '/issues/' . $number . '/labels';
165
166
		// Send the request.
167
		return $this->processResponse(
168
			$this->client->get($this->fetchUrl($path))
169
		);
170
	}
171
172
	/**
173
	 * Add labels to an issue.
174
	 *
175
	 * @param   string  $owner   The name of the owner of the GitHub repository.
176
	 * @param   string  $repo    The name of the GitHub repository.
177
	 * @param   string  $number  The issue number.
178
	 * @param   array   $labels  An array of labels to add.
179
	 *
180
	 * @return  object
181
	 *
182
	 * @since   1.0
183
	 */
184 View Code Duplication
	public function add($owner, $repo, $number, array $labels)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
185
	{
186
		// Build the request path.
187
		$path = '/repos/' . $owner . '/' . $repo . '/issues/' . $number . '/labels';
188
189
		// Send the request.
190
		return $this->processResponse(
191
			$this->client->post($this->fetchUrl($path), json_encode($labels))
192
		);
193
	}
194
195
	/**
196
	 * Remove a label from an issue.
197
	 *
198
	 * @param   string  $owner   The name of the owner of the GitHub repository.
199
	 * @param   string  $repo    The name of the GitHub repository.
200
	 * @param   string  $number  The issue number.
201
	 * @param   string  $name    The name of the label to remove.
202
	 *
203
	 * @return  object
204
	 *
205
	 * @since   1.0
206
	 */
207
	public function removeFromIssue($owner, $repo, $number, $name)
208
	{
209
		// Build the request path.
210
		$path = '/repos/' . $owner . '/' . $repo . '/issues/' . $number . '/labels/' . rawurlencode($name);
211
212
		// Send the request.
213
		return $this->processResponse(
214
			$this->client->delete($this->fetchUrl($path))
215
		);
216
	}
217
218
	/**
219
	 * Replace all labels for an issue.
220
	 *
221
	 * Sending an empty array ([]) will remove all Labels from the Issue.
222
	 *
223
	 * @param   string  $owner   The name of the owner of the GitHub repository.
224
	 * @param   string  $repo    The name of the GitHub repository.
225
	 * @param   string  $number  The issue number.
226
	 * @param   array   $labels  New labels
227
	 *
228
	 * @return  object
229
	 *
230
	 * @since   1.0
231
	 */
232 View Code Duplication
	public function replace($owner, $repo, $number, array $labels)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
233
	{
234
		// Build the request path.
235
		$path = '/repos/' . $owner . '/' . $repo . '/issues/' . $number . '/labels';
236
237
		// Send the request.
238
		return $this->processResponse(
239
			$this->client->put($this->fetchUrl($path), json_encode($labels))
240
		);
241
	}
242
243
	/**
244
	 * Remove all labels from an issue.
245
	 *
246
	 * @param   string  $owner   The name of the owner of the GitHub repository.
247
	 * @param   string  $repo    The name of the GitHub repository.
248
	 * @param   string  $number  The issue number.
249
	 *
250
	 * @return  object
251
	 *
252
	 * @since   1.0
253
	 */
254 View Code Duplication
	public function removeAllFromIssue($owner, $repo, $number)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
255
	{
256
		// Build the request path.
257
		$path = '/repos/' . $owner . '/' . $repo . '/issues/' . $number . '/labels';
258
259
		// Send the request.
260
		return $this->processResponse(
261
			$this->client->delete($this->fetchUrl($path)),
262
			204
263
		);
264
	}
265
266
	/**
267
	 * Get labels for every issue in a milestone.
268
	 *
269
	 * @param   string  $owner   The name of the owner of the GitHub repository.
270
	 * @param   string  $repo    The name of the GitHub repository.
271
	 * @param   string  $number  The issue number.
272
	 *
273
	 * @return  object
274
	 *
275
	 * @since   1.0
276
	 */
277
	public function getListByMilestone($owner, $repo, $number)
278
	{
279
		// Build the request path.
280
		$path = '/repos/' . $owner . '/' . $repo . '/milestones/' . $number . '/labels';
281
282
		// Send the request.
283
		return $this->processResponse(
284
			$this->client->get($this->fetchUrl($path))
285
		);
286
	}
287
}
288