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

Statuses::create()   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 36
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 15
nc 9
nop 7
dl 0
loc 36
rs 8.439
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\Repositories;
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/repos/statuses
17
 *
18
 * @since  1.0
19
 */
20
class Statuses extends AbstractPackage
21
{
22
	/**
23
	 * Create a Status.
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  $sha          The SHA1 value for which to set the status.
28
	 * @param   string  $state        The state (pending, success, error or failure).
29
	 * @param   string  $targetUrl    Optional target URL.
30
	 * @param   string  $description  Optional description for the status.
31
	 * @param   string  $context      A string label to differentiate this status from the status of other systems.
32
	 * 							      Default: "default"
33
	 *
34
	 * @throws \InvalidArgumentException
35
	 * @throws \DomainException
36
	 *
37
	 * @return object
38
	 *
39
	 * @since   1.0
40
	 *
41
	 */
42
	public function create($user, $repo, $sha, $state, $targetUrl = null, $description = null, $context = null)
43
	{
44
		// Build the request path.
45
		$path = "/repos/$user/$repo/statuses/$sha";
46
47
		if (!in_array($state, array('pending', 'success', 'error', 'failure')))
48
		{
49
			throw new \InvalidArgumentException('State must be one of pending, success, error or failure.');
50
		}
51
52
		// Build the request data.
53
		$data = array(
54
			'state' => $state
55
		);
56
57
		if (!is_null($targetUrl))
58
		{
59
			$data['target_url'] = $targetUrl;
60
		}
61
62
		if (!is_null($description))
63
		{
64
			$data['description'] = $description;
65
		}
66
67
		if (!is_null($context))
68
		{
69
			$data['context'] = $context;
70
		}
71
72
		// Send the request.
73
		return $this->processResponse(
74
			$this->client->post($this->fetchUrl($path), json_encode($data)),
75
			201
76
		);
77
	}
78
79
	/**
80
	 * List Statuses for a specific Ref.
81
	 *
82
	 * @param   string  $user  The name of the owner of the GitHub repository.
83
	 * @param   string  $repo  The name of the GitHub repository.
84
	 * @param   string  $sha   SHA1 for which to get the statuses.
85
	 *
86
	 * @return  array
87
	 *
88
	 * @since   1.0
89
	 */
90
	public function getList($user, $repo, $sha)
91
	{
92
		// Build the request path.
93
		$path = "/repos/$user/$repo/statuses/$sha";
94
95
		// Send the request.
96
		return $this->processResponse($this->client->get($this->fetchUrl($path)));
97
	}
98
99
	/**
100
	 * Get the combined Status for a specific Ref.
101
	 *
102
	 * @param   string  $user  The name of the owner of the GitHub repository.
103
	 * @param   string  $repo  The name of the GitHub repository.
104
	 * @param   string  $sha   SHA1 for which to get the combined status.
105
	 *
106
	 * @return  array
107
	 *
108
	 * @since   1.4.0
109
	 */
110
	public function getCombinedStatus($user, $repo, $sha)
111
	{
112
		// Build the request path.
113
		$path = "/repos/$user/$repo/commits/$sha/status";
114
115
		// Send the request.
116
		return $this->processResponse($this->client->get($this->fetchUrl($path)));
117
	}
118
}
119