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

Emails   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 61
Duplicated Lines 36.07 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getList() 0 9 1
A add() 10 10 1
A delete() 12 12 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\Users;
10
11
use Joomla\Github\AbstractPackage;
12
13
/**
14
 * GitHub API Emails class for the Joomla Framework.
15
 *
16
 * Management of email addresses via the API requires that you are authenticated
17
 * through basic auth or OAuth with the user scope.
18
 *
19
 * @documentation http://developer.github.com/v3/repos/users/emails
20
 *
21
 * @since  1.0
22
 */
23
class Emails extends AbstractPackage
24
{
25
	/**
26
	 * List email addresses for a user.
27
	 *
28
	 * @return  object
29
	 *
30
	 * @since   1.0
31
	 */
32
	public function getList()
33
	{
34
		// Build the request path.
35
		$path = '/user/emails';
36
37
		return $this->processResponse(
38
			$this->client->get($this->fetchUrl($path))
39
		);
40
	}
41
42
	/**
43
	 * Add email address(es).
44
	 *
45
	 * @param   string|array  $email  The email address(es).
46
	 *
47
	 * @return  object
48
	 *
49
	 * @since   1.0
50
	 */
51 View Code Duplication
	public function add($email)
0 ignored issues
show
Duplication introduced by
This method 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...
52
	{
53
		// Build the request path.
54
		$path = '/user/emails';
55
56
		return $this->processResponse(
57
			$this->client->post($this->fetchUrl($path), json_encode($email)),
58
			201
59
		);
60
	}
61
62
	/**
63
	 * Delete email address(es).
64
	 *
65
	 * @param   string|array  $email  The email address(es).
66
	 *
67
	 * @return  object
68
	 *
69
	 * @since   1.0
70
	 */
71 View Code Duplication
	public function delete($email)
0 ignored issues
show
Duplication introduced by
This method 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...
72
	{
73
		// Build the request path.
74
		$path = '/user/emails';
75
76
		$this->client->setOption('body', json_encode($email));
77
78
		return $this->processResponse(
79
			$this->client->delete($this->fetchUrl($path)),
80
			204
81
		);
82
	}
83
}
84