options = isset($options) ? $options : new JRegistry; $this->client = isset($client) ? $client : new JMediawikiHttp($this->options); } /** * Magic method to lazily create API objects * * @param string $name Name of property to retrieve * * @return JMediaWikiObject MediaWiki API object (users, reviews, etc). * * @since 12.3 * @throws InvalidArgumentException */ public function __get($name) { $name = strtolower($name); $class = 'JMediawiki' . ucfirst($name); $accessible = array( 'categories', 'images', 'links', 'pages', 'search', 'sites', 'users' ); if (class_exists($class) && in_array($name, $accessible)) { if (!isset($this->$name)) { $this->$name = new $class($this->options, $this->client); } return $this->$name; } throw new InvalidArgumentException(sprintf('Property %s is not accessible.', $name)); } /** * Get an option from the JMediawiki instance. * * @param string $key The name of the option to get. * * @return mixed The option value. * * @since 12.3 */ public function getOption($key) { return $this->options->get($key); } /** * Set an option for the JMediawiki instance. * * @param string $key The name of the option to set. * @param mixed $value The option value to set. * * @return JMediawiki This object for method chaining. * * @since 12.3 */ public function setOption($key, $value) { $this->options->set($key, $value); return $this; } }