public function __call($name, $arguments)
{
if (array_key_exists($name, $validSubResources = $this::getValidSubResources())) {
$className = $validSubResources[$name];
$client = $this instanceof HttpClient ? $this : $this->client;
$class = new $className($client);
} else {
throw new \Exception("No method called {$name} available in " . __CLASS__);
}
$chainedParams = $this instanceof ResourceAbstract ? $this->getChainedParameters() : [];
if (isset($arguments[0]) && $arguments[0] != null) {
$chainedParams = array_merge($chainedParams, [get_class($class) => $arguments[0]]);
}
$class = $class->setChainedParameters($chainedParams);
return $class;
}