Wrap wait

This commit is contained in:
Daniil Gentili 2019-06-22 16:34:46 +02:00
parent 119e29f4a7
commit 2d2a3bd01f

View File

@ -258,12 +258,18 @@ class MyTelegramOrgWrapper
{
$this->async = $async;
}
public function loop($callable)
{
return $this->wait($callable());
}
public function __call($name, $arguments)
{
$name .= '_async';
$async = is_array(end($arguments)) && isset(end($arguments)['async']) ? end($arguments)['async'] : $this->async;
if (!method_exists($this, $name)) {
throw new Exception("$name does not exist!");
}
return $async ? $this->{$name}(...$arguments) : $this->wait($this->{$name}(...$arguments));
}
}