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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 12.07 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 7
loc 58
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getList() 0 9 1
B get() 7 25 5

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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