Completed
Push — master ( da17ac...286914 )
by George
03:50
created

GitHub   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 1
dl 29
loc 29
ccs 0
cts 13
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __get() 16 16 3

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
namespace Stats\GitHub;
4
5
use Joomla\Github\Github as JGitHub;
6
7
/**
8
 * Extended GitHub API object.
9
 *
10
 * @property-read  Package\Repositories   $repositories   GitHub API object for the repositories package.
11
 *
12
 * @since  1.0
13
 */
14 View Code Duplication
class GitHub extends JGitHub
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...
15
{
16
	/**
17
	 * Magic method to lazily create API objects
18
	 *
19
	 * @param   string  $name  Name of property to retrieve
20
	 *
21
	 * @return  \Joomla\Github\AbstractGithubObject  GitHub API object (gists, issues, pulls, etc).
22
	 *
23
	 * @since   1.0
24
	 * @throws  \InvalidArgumentException If $name is not a valid sub class.
25
	 */
26
	public function __get($name)
27
	{
28
		$class = __NAMESPACE__ . '\\Package\\' . ucfirst($name);
29
30
		if (class_exists($class))
31
		{
32
			if (false == isset($this->$name))
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...
33
			{
34
				$this->$name = new $class($this->options, $this->client);
35
			}
36
37
			return $this->$name;
38
		}
39
40
		return parent::__get($name);
41
	}
42
}
43