| @@ 18-46 (lines=29) @@ | ||
| 15 | * |
|
| 16 | * @property-read Package\Repositories $repositories GitHub API object for the repositories package. |
|
| 17 | */ |
|
| 18 | class GitHub extends JGitHub |
|
| 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)) |
|
| 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 | ||
| @@ 16-44 (lines=29) @@ | ||
| 13 | /** |
|
| 14 | * Extended GitHub API package class. |
|
| 15 | */ |
|
| 16 | abstract class Package extends BasePackage |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * Magic method to lazily create API objects |
|
| 20 | * |
|
| 21 | * @param string $name Name of property to retrieve |
|
| 22 | * |
|
| 23 | * @return Package GitHub API package object. |
|
| 24 | * |
|
| 25 | * @throws \InvalidArgumentException |
|
| 26 | */ |
|
| 27 | public function __get($name) |
|
| 28 | { |
|
| 29 | $class = __NAMESPACE__ . '\\' . $this->package . '\\' . ucfirst($name); |
|
| 30 | ||
| 31 | if (class_exists($class)) |
|
| 32 | { |
|
| 33 | if (false == isset($this->$name)) |
|
| 34 | { |
|
| 35 | $this->$name = new $class($this->options, $this->client); |
|
| 36 | } |
|
| 37 | ||
| 38 | return $this->$name; |
|
| 39 | } |
|
| 40 | ||
| 41 | return parent::__get($name); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||