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.

Search   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 115
Duplicated Lines 21.74 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A issues() 0 15 2
A repositories() 13 13 3
A users() 12 12 2
A email() 0 10 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 - 2018 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
13
/**
14
 * GitHub API Search class for the Joomla Framework.
15
 *
16
 * @link   https://developer.github.com/v3/search
17
 *
18
 * @since  1.0
19
 */
20
class Search extends AbstractPackage
21
{
22
	/**
23
	 * Search issues.
24
	 *
25
	 * @param   string  $owner    The name of the owner of the repository.
26
	 * @param   string  $repo     The name of the repository.
27
	 * @param   string  $state    The state - open or closed.
28
	 * @param   string  $keyword  The search term.
29
	 *
30
	 * @return  object
31
	 *
32
	 * @since   1.0
33
	 * @throws  \UnexpectedValueException
34
	 * @deprecated  The legacy API is deprecated
35
	 */
36
	public function issues($owner, $repo, $state, $keyword)
37
	{
38
		if (false == in_array($state, array('open', 'close')))
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
39
		{
40
			throw new \UnexpectedValueException('State must be either "open" or "closed"');
41
		}
42
43
		// Build the request path.
44
		$path = '/legacy/issues/search/' . $owner . '/' . $repo . '/' . $state . '/' . $keyword;
45
46
		// Send the request.
47
		return $this->processResponse(
48
			$this->client->get($this->fetchUrl($path))
49
		);
50
	}
51
52
	/**
53
	 * Search repositories.
54
	 *
55
	 * Find repositories by keyword. Note, this legacy method does not follow
56
	 * the v3 pagination pattern.
57
	 * This method returns up to 100 results per page and pages can be fetched
58
	 * using the start_page parameter.
59
	 *
60
	 * @param   string   $keyword    The search term.
61
	 * @param   string   $language   Filter results by language https://github.com/languages
62
	 * @param   integer  $startPage  Page number to fetch
63
	 *
64
	 * @return  object
65
	 *
66
	 * @since   1.0
67
	 * @deprecated  The legacy API is deprecated
68
	 */
69 View Code Duplication
	public function repositories($keyword, $language = '', $startPage = 0)
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...
70
	{
71
		// Build the request path.
72
		$path = '/legacy/repos/search/' . $keyword . '?';
73
74
		$path .= ($language) ? '&language=' . $language : '';
75
		$path .= ($startPage) ? '&start_page=' . $startPage : '';
76
77
		// Send the request.
78
		return $this->processResponse(
79
			$this->client->get($this->fetchUrl($path))
80
		);
81
	}
82
83
	/**
84
	 * Search users.
85
	 *
86
	 * Find users by keyword.
87
	 *
88
	 * @param   string   $keyword    The search term.
89
	 * @param   integer  $startPage  Page number to fetch
90
	 *
91
	 * @return  object
92
	 *
93
	 * @since   1.0
94
	 * @deprecated  The legacy API is deprecated
95
	 */
96 View Code Duplication
	public function users($keyword, $startPage = 0)
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...
97
	{
98
		// Build the request path.
99
		$path = '/legacy/user/search/' . $keyword . '?';
100
101
		$path .= ($startPage) ? '&start_page=' . $startPage : '';
102
103
		// Send the request.
104
		return $this->processResponse(
105
			$this->client->get($this->fetchUrl($path))
106
		);
107
	}
108
109
	/**
110
	 * Email search.
111
	 *
112
	 * This API call is added for compatibility reasons only. There’s no guarantee
113
	 * that full email searches will always be available. The @ character in the
114
	 * address must be left unencoded. Searches only against public email addresses
115
	 * (as configured on the user’s GitHub profile).
116
	 *
117
	 * @param   string  $email  The email address(es).
118
	 *
119
	 * @return  object
120
	 *
121
	 * @since   1.0
122
	 * @deprecated  The legacy API is deprecated
123
	 */
124
	public function email($email)
125
	{
126
		// Build the request path.
127
		$path = '/legacy/user/email/' . $email;
128
129
		// Send the request.
130
		return $this->processResponse(
131
			$this->client->get($this->fetchUrl($path))
132
		);
133
	}
134
}
135