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

Gitignore::get()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 25
Code Lines 11

Duplication

Lines 7
Ratio 28 %

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 8
nop 2
dl 7
loc 25
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;
10
11
use Joomla\Github\AbstractPackage;
12
use Joomla\Http\Exception\UnexpectedResponseException;
13
14
/**
15
 * GitHub API Gitignore class for the Joomla Framework.
16
 *
17
 * The .gitignore Templates API lists and fetches templates from the GitHub .gitignore repository.
18
 *
19
 * @documentation  http://developer.github.com/v3/gitignore
20
 * @documentation  https://github.com/github/gitignore
21
 *
22
 * @since  1.0
23
 */
24
class Gitignore extends AbstractPackage
25
{
26
	/**
27
	 * Listing available templates
28
	 *
29
	 * List all templates available to pass as an option when creating a repository.
30
	 *
31
	 * @return  object
32
	 *
33
	 * @since   1.0
34
	 */
35
	public function getList()
36
	{
37
		// Build the request path.
38
		$path = '/gitignore/templates';
39
40
		return $this->processResponse(
41
			$this->client->get($this->fetchUrl($path))
42
		);
43
	}
44
45
	/**
46
	 * Get a single template
47
	 *
48
	 * @param   string   $name  The name of the template
49
	 * @param   boolean  $raw   Raw output
50
	 *
51
	 * @return  mixed|string
52
	 *
53
	 * @since   1.0
54
	 * @throws  UnexpectedResponseException
55
	 */
56
	public function get($name, $raw = false)
57
	{
58
		// Build the request path.
59
		$path = '/gitignore/templates/' . $name;
60
61
		$headers = array();
62
63
		if ($raw)
64
		{
65
			$headers['Accept'] = 'application/vnd.github.raw+json';
66
		}
67
68
		$response = $this->client->get($this->fetchUrl($path), $headers);
69
70
		// Validate the response code.
71 View Code Duplication
		if ($response->code != 200)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
72
		{
73
			// Decode the error response and throw an exception.
74
			$error = json_decode($response->body);
75
			$message = isset($error->message) ? $error->message : 'Invalid response received from GitHub.';
76
			throw new UnexpectedResponseException($response, $message, $response->code);
77
		}
78
79
		return ($raw) ? $response->body : json_decode($response->body);
80
	}
81
}
82