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

Package   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\Package as BasePackage;
6
7
/**
8
 * Extended GitHub API package class.
9
 *
10
 * @since  1.0
11
 */
12 View Code Duplication
abstract class Package extends BasePackage
0 ignored issues
show
Deprecated Code introduced by
The class Joomla\Github\Package has been deprecated with message: Use AbstractPackage instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
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...
13
{
14
	/**
15
	 * Magic method to lazily create API objects
16
	 *
17
	 * @param   string  $name  Name of property to retrieve
18
	 *
19
	 * @return  Package  GitHub API package object.
20
	 *
21
	 * @since   1.0
22
	 * @throws  \InvalidArgumentException
23
	 */
24
	public function __get($name)
25
	{
26
		$class = __NAMESPACE__ . '\\' . $this->package . '\\' . ucfirst($name);
27
28
		if (class_exists($class))
29
		{
30
			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...
31
			{
32
				$this->$name = new $class($this->options, $this->client);
33
			}
34
35
			return $this->$name;
36
		}
37
38
		return parent::__get($name);
39
	}
40
}
41