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
02:03
created

Blobs   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 51
loc 51
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 Blobs class for the Joomla Framework.
15
 *
16
 * Since blobs can be any arbitrary binary data, the input and responses for the blob API
17
 * takes an encoding parameter that can be either utf-8 or base64. If your data cannot be
18
 * losslessly sent as a UTF-8 string, you can base64 encode it.
19
 *
20
 * @documentation http://developer.github.com/v3/git/blobs/
21
 *
22
 * @since  1.0
23
 */
24 View Code Duplication
class Blobs 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...
25
{
26
	/**
27
	 * Get a Blob.
28
	 *
29
	 * @param   string  $owner  Repository owner.
30
	 * @param   string  $repo   Repository name.
31
	 * @param   string  $sha    The commit SHA.
32
	 *
33
	 * @return  object
34
	 *
35
	 * @since   1.0
36
	 */
37
	public function get($owner, $repo, $sha)
38
	{
39
		// Build the request path.
40
		$path = '/repos/' . $owner . '/' . $repo . '/git/blobs/' . $sha;
41
42
		return $this->processResponse(
43
			$this->client->get($this->fetchUrl($path))
44
		);
45
	}
46
47
	/**
48
	 * Create a Blob.
49
	 *
50
	 * @param   string  $owner     Repository owner.
51
	 * @param   string  $repo      Repository name.
52
	 * @param   string  $content   The content of the blob.
53
	 * @param   string  $encoding  The encoding to use.
54
	 *
55
	 * @return  object
56
	 *
57
	 * @since   1.0
58
	 */
59
	public function create($owner, $repo, $content, $encoding = 'utf-8')
60
	{
61
		// Build the request path.
62
		$path = '/repos/' . $owner . '/' . $repo . '/git/blobs';
63
64
		$data = array(
65
			'content'  => $content,
66
			'encoding' => $encoding
67
		);
68
69
		return $this->processResponse(
70
			$this->client->post($this->fetchUrl($path), json_encode($data)),
71
			201
72
		);
73
	}
74
}
75