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
Push — develop ( b5e3c2...7799bc )
by
unknown
15s
created

Refs::edit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 5
dl 0
loc 22
rs 9.2
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\Data;
10
11
use Joomla\Github\AbstractPackage;
12
13
/**
14
 * GitHub API References class for the Joomla Framework.
15
 *
16
 * @documentation http://developer.github.com/v3/git/refs/
17
 *
18
 * @since  1.0
19
 */
20
class Refs extends AbstractPackage
21
{
22
	/**
23
	 * Get a Reference.
24
	 *
25
	 * @param   string  $user  The name of the owner of the GitHub repository.
26
	 * @param   string  $repo  The name of the GitHub repository.
27
	 * @param   string  $ref   The reference to get.
28
	 *
29
	 * @return  object
30
	 *
31
	 * @since   1.0
32
	 * @throws  \DomainException
33
	 */
34
	public function get($user, $repo, $ref)
35
	{
36
		// Build the request path.
37
		$path = '/repos/' . $user . '/' . $repo . '/git/refs/' . $ref;
38
39
		// Send the request.
40
		return $this->processResponse($this->client->get($this->fetchUrl($path)));
41
	}
42
43
	/**
44
	 * Get all References.
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   $namespace  Optional sub-namespace to limit the returned references.
49
	 * @param   integer  $page       Page to request
50
	 * @param   integer  $limit      Number of results to return per page
51
	 *
52
	 * @return  object
53
	 *
54
	 * @since   1.0
55
	 * @throws  \DomainException
56
	 */
57
	public function getList($user, $repo, $namespace = '', $page = 0, $limit = 0)
58
	{
59
		// Build the request path.
60
		$path = '/repos/' . $user . '/' . $repo . '/git/refs';
61
62
		if (!empty($namespace))
63
		{
64
			$path .= '/' . $namespace;
65
		}
66
67
		// Send the request.
68
		return $this->processResponse($this->client->get($this->fetchUrl($path, $page, $limit)));
69
	}
70
71
	/**
72
	 * Create a Reference.
73
	 *
74
	 * @param   string  $user  The name of the owner of the GitHub repository.
75
	 * @param   string  $repo  The name of the GitHub repository.
76
	 * @param   string  $ref   The name of the fully qualified reference.
77
	 * @param   string  $sha   The SHA1 value to set this reference to.
78
	 *
79
	 * @return  object
80
	 *
81
	 * @since   1.0
82
	 * @throws  \DomainException
83
	 */
84
	public function create($user, $repo, $ref, $sha)
85
	{
86
		// Build the request path.
87
		$path = '/repos/' . $user . '/' . $repo . '/git/refs';
88
89
		// Build the request data.
90
		$data = json_encode(
91
			array(
92
				'ref' => $ref,
93
				'sha' => $sha
94
			)
95
		);
96
97
		// Send the request.
98
		return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
99
	}
100
101
	/**
102
	 * Update a Reference.
103
	 *
104
	 * @param   string   $user   The name of the owner of the GitHub repository.
105
	 * @param   string   $repo   The name of the GitHub repository.
106
	 * @param   string   $ref    The reference to update.
107
	 * @param   string   $sha    The SHA1 value to set the reference to.
108
	 * @param   boolean  $force  Whether the update should be forced. Default to false.
109
	 *
110
	 * @return  object
111
	 *
112
	 * @since   1.0
113
	 * @throws  DomainException
114
	 */
115
	public function edit($user, $repo, $ref, $sha, $force = false)
116
	{
117
		// Build the request path.
118
		$path = '/repos/' . $user . '/' . $repo . '/git/refs/' . $ref;
119
120
		// Create the data object.
121
		$data = new \stdClass;
122
123
		// If a title is set add it to the data object.
124
		if ($force)
125
		{
126
			$data->force = true;
127
		}
128
129
		$data->sha = $sha;
130
131
		// Encode the request data.
132
		$data = json_encode($data);
133
134
		// Send the request.
135
		return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
136
	}
137
138
	/**
139
	 * Delete a Reference
140
	 *
141
	 * @param   string  $owner  The name of the owner of the GitHub repository.
142
	 * @param   string  $repo   The name of the GitHub repository.
143
	 * @param   string  $ref    The reference to update.
144
	 *
145
	 * @return  object
146
	 *
147
	 * @since   1.0
148
	 */
149 View Code Duplication
	public function delete($owner, $repo, $ref)
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...
150
	{
151
		// Build the request path.
152
		$path = '/repos/' . $owner . '/' . $repo . '/git/refs/' . $ref;
153
154
		return $this->processResponse(
155
			$this->client->delete($this->fetchUrl($path)),
156
			204
157
		);
158
	}
159
}
160