Completed
Push — mysql_improvements ( 2e95ce...dedbef )
by Michael
03:52
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 0
Metric Value
dl 16
loc 16
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
crap 12
1
<?php
2
/**
3
 * Joomla! Statistics Server
4
 *
5
 * @copyright  Copyright (C) 2013 - 2017 Open Source Matters, Inc. All rights reserved.
6
 * @license    http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
7
 */
8
9
namespace Joomla\StatsServer\GitHub;
10
11
use Joomla\Github\Github as JGitHub;
12
13
/**
14
 * Extended GitHub API object.
15
 *
16
 * @property-read  Package\Repositories   $repositories   GitHub API object for the repositories package.
17
 */
18 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...
19
{
20
	/**
21
	 * Magic method to lazily create API objects
22
	 *
23
	 * @param   string  $name  Name of property to retrieve
24
	 *
25
	 * @return  \Joomla\Github\AbstractGithubObject  GitHub API object (gists, issues, pulls, etc).
26
	 *
27
	 * @throws  \InvalidArgumentException If $name is not a valid sub class.
28
	 */
29
	public function __get($name)
30
	{
31
		$class = __NAMESPACE__ . '\\Package\\' . ucfirst($name);
32
33
		if (class_exists($class))
34
		{
35
			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...
36
			{
37
				$this->$name = new $class($this->options, $this->client);
38
			}
39
40
			return $this->$name;
41
		}
42
43
		return parent::__get($name);
44
	}
45
}
46