| @@ 20-48 (lines=29) @@ | ||
| 17 | * |
|
| 18 | * @since 1.0 |
|
| 19 | */ |
|
| 20 | class GitHub extends JGitHub |
|
| 21 | { |
|
| 22 | /** |
|
| 23 | * Magic method to lazily create API objects |
|
| 24 | * |
|
| 25 | * @param string $name Name of property to retrieve |
|
| 26 | * |
|
| 27 | * @return \Joomla\Github\AbstractGithubObject GitHub API object (gists, issues, pulls, etc). |
|
| 28 | * |
|
| 29 | * @since 1.0 |
|
| 30 | * @throws \InvalidArgumentException If $name is not a valid sub class. |
|
| 31 | */ |
|
| 32 | public function __get($name) |
|
| 33 | { |
|
| 34 | $class = __NAMESPACE__ . '\\Package\\' . ucfirst($name); |
|
| 35 | ||
| 36 | if (class_exists($class)) |
|
| 37 | { |
|
| 38 | if (false == isset($this->$name)) |
|
| 39 | { |
|
| 40 | $this->$name = new $class($this->options, $this->client); |
|
| 41 | } |
|
| 42 | ||
| 43 | return $this->$name; |
|
| 44 | } |
|
| 45 | ||
| 46 | return parent::__get($name); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 18-46 (lines=29) @@ | ||
| 15 | * |
|
| 16 | * @since 1.0 |
|
| 17 | */ |
|
| 18 | abstract class Package extends BasePackage |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * Magic method to lazily create API objects |
|
| 22 | * |
|
| 23 | * @param string $name Name of property to retrieve |
|
| 24 | * |
|
| 25 | * @return Package GitHub API package object. |
|
| 26 | * |
|
| 27 | * @since 1.0 |
|
| 28 | * @throws \InvalidArgumentException |
|
| 29 | */ |
|
| 30 | public function __get($name) |
|
| 31 | { |
|
| 32 | $class = __NAMESPACE__ . '\\' . $this->package . '\\' . ucfirst($name); |
|
| 33 | ||
| 34 | if (class_exists($class)) |
|
| 35 | { |
|
| 36 | if (false == isset($this->$name)) |
|
| 37 | { |
|
| 38 | $this->$name = new $class($this->options, $this->client); |
|
| 39 | } |
|
| 40 | ||
| 41 | return $this->$name; |
|
| 42 | } |
|
| 43 | ||
| 44 | return parent::__get($name); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||