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.
Completed
Pull Request — develop (#322)
by
unknown
01:46
created

Assignees::remove()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 4
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Part of the Joomla Framework Github Package
4
 *
5
 * @copyright  Copyright (C) 2005 - 2015 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
use Joomla\Http\Exception\UnexpectedResponseException;
13
14
/**
15
 * GitHub API Assignees class for the Joomla Framework.
16
 *
17
 * @documentation http://developer.github.com/v3/issues/assignees/
18
 *
19
 * @since  1.0
20
 */
21
class Assignees extends AbstractPackage
22
{
23
	/**
24
	 * List assignees.
25
	 *
26
	 * This call lists all the available assignees (owner + collaborators) to which issues may be assigned.
27
	 *
28
	 * @param   string  $owner  The name of the owner of the GitHub repository.
29
	 * @param   string  $repo   The name of the GitHub repository.
30
	 *
31
	 * @return  object
32
	 *
33
	 * @since   1.0
34
	 */
35
	public function getList($owner, $repo)
36
	{
37
		// Build the request path.
38
		$path = '/repos/' . $owner . '/' . $repo . '/assignees';
39
40
		return $this->processResponse(
41
			$this->client->get($this->fetchUrl($path))
42
		);
43
	}
44
45
	/**
46
	 * Check assignee.
47
	 *
48
	 * You may check to see if a particular user is an assignee for a repository.
49
	 * If the given assignee login belongs to an assignee for the repository, a 204 header
50
	 * with no content is returned.
51
	 * Otherwise a 404 status code is returned.
52
	 *
53
	 * @param   string  $owner     The name of the owner of the GitHub repository.
54
	 * @param   string  $repo      The name of the GitHub repository.
55
	 * @param   string  $assignee  The assignees login name.
56
	 *
57
	 * @return  boolean
58
	 *
59
	 * @since   1.0
60
	 * @throws  \DomainException
61
	 */
62
	public function check($owner, $repo, $assignee)
63
	{
64
		// Build the request path.
65
		$path = '/repos/' . $owner . '/' . $repo . '/assignees/' . $assignee;
66
67
		try
68
		{
69
			$response = $this->client->get($this->fetchUrl($path));
70
71
			if (204 == $response->code)
72
			{
73
				return true;
74
			}
75
76
			throw new UnexpectedResponseException($response, 'Invalid response: ' . $response->code);
77
		}
78
		catch (\DomainException $e)
79
		{
80
			if (isset($response->code) && 404 == $response->code)
81
			{
82
				return false;
83
			}
84
85
			throw $e;
86
		}
87
	}
88
89
	/**
90
	 * Add assignees to an Issue
91
	 *
92
	 * This call adds the users passed in the assignees key (as their logins) to the issue.
93
	 *
94
	 * @param   string    $owner      The name of the owner of the GitHub repository.
95
	 * @param   string    $repo       The name of the GitHub repository.
96
	 * @param   integer   $number     The issue number to add assignees to.
97
	 * @param   string[]  $assignees  The logins for GitHub users to assign to this issue.
98
	 *
99
	 * @return  object
100
	 *
101
	 * @since   1.4.0
102
	 * @throws  \DomainException
103
	 */
104 View Code Duplication
	public function add($owner, $repo, $number, array $assignees)
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...
105
	{
106
		// Build the request path.
107
		$path = "/repos/$owner/$repo/issues/$number/assignees";
108
109
		$data = json_encode(
110
			array(
111
				'assignees' => $assignees,
112
			)
113
		);
114
115
		return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
116
	}
117
118
	/**
119
	 * Remove assignees from an Issue
120
	 *
121
	 * This call removes the users passed in the assignees key (as their logins) from the issue.
122
	 *
123
	 * @param   string    $owner      The name of the owner of the GitHub repository.
124
	 * @param   string    $repo       The name of the GitHub repository.
125
	 * @param   integer   $number     The issue number to add assignees to.
126
	 * @param   string[]  $assignees  The logins for GitHub users to assign to this issue.
127
	 *
128
	 * @return  object
129
	 *
130
	 * @since   1.4.0
131
	 * @throws  \DomainException
132
	 */
133 View Code Duplication
	public function remove($owner, $repo, $number, array $assignees)
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...
134
	{
135
		// Build the request path.
136
		$path = "/repos/$owner/$repo/issues/$number/assignees";
137
138
		$data = json_encode(
139
			array(
140
				'assignees' => $assignees,
141
			)
142
		);
143
144
		return $this->processResponse($this->client->delete($this->fetchUrl($path), array(), null, $data));
145
	}
146
}
147