public function __call($method, $arguments)
{
if (preg_match('/^\\w+Commands?/', $method, $matches)) {
return call_user_func_array([$this->getCommandBus(), $matches[0]], $arguments);
}
$action = substr($method, 0, 3);
if ($action === 'get') {
/* @noinspection PhpUndefinedFunctionInspection */
$class_name = studly_case(substr($method, 3));
$class = 'Telegram\\Bot\\Objects\\' . $class_name;
$response = $this->post($method, $arguments[0] ?: []);
if (class_exists($class)) {
return new $class($response->getDecodedBody());
}
return $response;
}
$response = $this->post($method, $arguments[0]);
return new UnknownObject($response->getDecodedBody());
}