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

Github::__get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 7

Duplication

Lines 4
Ratio 25 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 4
loc 16
rs 9.4285
c 0
b 0
f 0
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
 * Joomla Framework class for interacting with a GitHub server instance.
15
 *
16
 * @property-read  Package\Activity       $activity       GitHub API object for the activity package.
17
 * @property-read  Package\Authorization  $authorization  GitHub API object for the authorizations package.
18
 * @property-read  Package\Data           $data           GitHub API object for the data package.
19
 * @property-read  Package\Emojis         $emojis         GitHub API object for the emojis package.
20
 * @property-read  Package\Gists          $gists          GitHub API object for the gists package.
21
 * @property-read  Package\Gitignore      $gitignore      GitHub API object for the gitignore package.
22
 * @property-read  Package\Issues         $issues         GitHub API object for the issues package.
23
 * @property-read  Package\Markdown       $markdown       GitHub API object for the markdown package.
24
 * @property-read  Package\Meta           $meta           GitHub API object for the meta package.
25
 * @property-read  Package\Orgs           $orgs           GitHub API object for the orgs package.
26
 * @property-read  Package\Pulls          $pulls          GitHub API object for the pulls package.
27
 * @property-read  Package\Repositories   $repositories   GitHub API object for the repositories package.
28
 * @property-read  Package\Search         $search         GitHub API object for the search package.
29
 * @property-read  Package\Users          $users          GitHub API object for the users package.
30
 * @property-read  Package\Zen            $zen            GitHub API object for the zen package.
31
 *
32
 * @since  1.0
33
 */
34
class Github
35
{
36
	/**
37
	 * @var    array  Options for the GitHub object.
38
	 * @since  1.0
39
	 */
40
	protected $options;
41
42
	/**
43
	 * @var    Http  The HTTP client object to use in sending HTTP requests.
44
	 * @since  1.0
45
	 */
46
	protected $client;
47
48
	/**
49
	 * Constructor.
50
	 *
51
	 * @param   Registry  $options  GitHub options object.
52
	 * @param   Http      $client   The HTTP client object.
53
	 *
54
	 * @since   1.0
55
	 */
56
	public function __construct(Registry $options = null, Http $client = null)
57
	{
58
		$this->options = isset($options) ? $options : new Registry;
0 ignored issues
show
Documentation Bug introduced by
It seems like isset($options) ? $optio...mla\Registry\Registry() of type object<Joomla\Registry\Registry> is incompatible with the declared type array of property $options.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
59
		$this->client  = isset($client) ? $client : new Http($this->options);
60
61
		// Setup the default API url if not already set.
62
		if (!$this->getOption('api.url'))
63
		{
64
			$this->setOption('api.url', 'https://api.github.com');
65
		}
66
	}
67
68
	/**
69
	 * Magic method to lazily create API objects
70
	 *
71
	 * @param   string  $name  Name of property to retrieve
72
	 *
73
	 * @return  Object  GitHub API object (gists, issues, pulls, etc).
74
	 *
75
	 * @since   1.0
76
	 * @throws  \InvalidArgumentException If $name is not a valid sub class.
77
	 */
78
	public function __get($name)
79
	{
80
		$class = 'Joomla\\Github\\Package\\' . ucfirst($name);
81
82
		if (class_exists($class))
83
		{
84 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...
85
			{
86
				$this->$name = new $class($this->options, $this->client);
87
			}
88
89
			return $this->$name;
90
		}
91
92
		throw new \InvalidArgumentException(sprintf('Argument %s produced an invalid class name: %s', $name, $class));
93
	}
94
95
	/**
96
	 * Get an option from the GitHub instance.
97
	 *
98
	 * @param   string  $key  The name of the option to get.
99
	 *
100
	 * @return  mixed  The option value.
101
	 *
102
	 * @since   1.0
103
	 */
104
	public function getOption($key)
105
	{
106
		return isset($this->options[$key]) ? $this->options[$key] : null;
107
	}
108
109
	/**
110
	 * Set an option for the GitHub instance.
111
	 *
112
	 * @param   string  $key    The name of the option to set.
113
	 * @param   mixed   $value  The option value to set.
114
	 *
115
	 * @return  GitHub  This object for method chaining.
116
	 *
117
	 * @since   1.0
118
	 */
119
	public function setOption($key, $value)
120
	{
121
		$this->options[$key] = $value;
122
123
		return $this;
124
	}
125
}
126