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:57
created

Commits   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 53
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 53
loc 53
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 9 9 1
A create() 15 15 1

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\Data;
10
11
use Joomla\Github\AbstractPackage;
12
13
/**
14
 * GitHub API Data Commits class for the Joomla Framework.
15
 *
16
 * @documentation http://developer.github.com/v3/git/commits/
17
 *
18
 * @since  1.0
19
 */
20 View Code Duplication
class Commits extends AbstractPackage
0 ignored issues
show
Duplication introduced by
This class 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...
21
{
22
	/**
23
	 * Get a Commit.
24
	 *
25
	 * @param   string  $owner  The name of the owner of the GitHub repository.
26
	 * @param   string  $repo   The name of the GitHub repository.
27
	 * @param   string  $sha    The commit SHA.
28
	 *
29
	 * @return object
30
	 */
31
	public function get($owner, $repo, $sha)
32
	{
33
		// Build the request path.
34
		$path = '/repos/' . $owner . '/' . $repo . '/git/commits/' . $sha;
35
36
		return $this->processResponse(
37
			$this->client->get($this->fetchUrl($path))
38
		);
39
	}
40
41
	/**
42
	 * Create a Commit.
43
	 *
44
	 * @param   string  $owner    The name of the owner of the GitHub repository.
45
	 * @param   string  $repo     The name of the GitHub repository.
46
	 * @param   string  $message  The commit message.
47
	 * @param   string  $tree     SHA of the tree object this commit points to.
48
	 * @param   array   $parents  Array of the SHAs of the commits that were the parents of this commit.
49
	 *                            If omitted or empty, the commit will be written as a root commit.
50
	 *                            For a single parent, an array of one SHA should be provided.
51
	 *                            For a merge commit, an array of more than one should be provided.
52
	 *
53
	 * @since   1.0
54
	 *
55
	 * @return  object
56
	 */
57
	public function create($owner, $repo, $message, $tree, array $parents = array())
58
	{
59
		// Build the request path.
60
		$path = '/repos/' . $owner . '/' . $repo . '/git/commits';
61
62
		$data = json_encode(
63
			array('message' => $message, 'tree' => $tree, 'parents' => $parents)
64
		);
65
66
		// Send the request.
67
		return $this->processResponse(
68
			$response = $this->client->post($this->fetchUrl($path), $data),
69
			201
70
		);
71
	}
72
}
73