public function registerMethod(string $class, string $method, bool $useFullName = true) : self
{
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Třída %s neexistuje.', $class));
}
// If magic methods exist, always register
if (!method_exists($class, '__call') && !method_exists($class, '__callStatic')) {
try {
$reflection = new \ReflectionMethod($class, $method);
} catch (\ReflectionException $e) {
throw new \InvalidArgumentException(sprintf('Method %s::%s does not exist.', $class, $method));
}
// Only public methods
if (!$reflection->isPublic()) {
throw new \InvalidArgumentException(sprintf('Method %s::%s is not public.', $class, $method));
}
}
$func = $class . '::' . $method;
// Save short name as an alias
if (!$useFullName) {
$this->aliases[$method] = $func;
$func = $method;
}
$this->register($func);
return $this;
}