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.
Completed
Push — develop ( b5e3c2...7799bc )
by
unknown
15s
created

AbstractPackage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 8 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 4
loc 50
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A __get() 4 21 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
 * Part of the Joomla Framework Github Package
4
 *
5
 * @copyright  Copyright (C) 2005 - 2015 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;
10
11
use Joomla\Registry\Registry;
12
13
/**
14
 * GitHub API package class for the Joomla Framework.
15
 *
16
 * @since  1.0
17
 */
18
abstract class AbstractPackage extends AbstractGithubObject
19
{
20
	/**
21
	 * Constructor.
22
	 *
23
	 * @param   Registry  $options  GitHub options object.
24
	 * @param   Http      $client   The HTTP client object.
25
	 *
26
	 * @since   1.0
27
	 */
28
	public function __construct(Registry $options = null, Http $client = null)
29
	{
30
		parent::__construct($options, $client);
31
32
		$this->package = get_class($this);
33
		$this->package = substr($this->package, strrpos($this->package, '\\') + 1);
34
	}
35
36
	/**
37
	 * Magic method to lazily create API objects
38
	 *
39
	 * @param   string  $name  Name of property to retrieve
40
	 *
41
	 * @since   1.0
42
	 * @throws \InvalidArgumentException
43
	 *
44
	 * @return  AbstractPackage  GitHub API package object.
45
	 */
46
	public function __get($name)
47
	{
48
		$class = '\\Joomla\\Github\\Package\\' . $this->package . '\\' . ucfirst($name);
49
50
		if (false == class_exists($class))
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...
51
		{
52
			throw new \InvalidArgumentException(
53
				sprintf(
54
					'Argument %1$s produced an invalid class name: %2$s in package %3$s',
55
					$name, $class, $this->package
56
				)
57
			);
58
		}
59
60 View Code Duplication
		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...
Duplication introduced by
This code seems to be duplicated across 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...
61
		{
62
			$this->$name = new $class($this->options, $this->client);
63
		}
64
65
		return $this->$name;
66
	}
67
}
68