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

GitHub::__get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 7

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 16
loc 16
ccs 0
cts 13
cp 0
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
crap 12
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