Code Duplication    Length = 29-29 lines in 2 locations

src/GitHub/GitHub.php 1 location

@@ 14-42 (lines=29) @@
11
 *
12
 * @since  1.0
13
 */
14
class GitHub extends JGitHub
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))
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

src/GitHub/Package.php 1 location

@@ 12-40 (lines=29) @@
9
 *
10
 * @since  1.0
11
 */
12
abstract class Package extends BasePackage
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))
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