public function addHandler(\closure $handler, array $arguments, $priority = 0)
{
$invoke = new \reflectionMethod($handler, '__invoke');
if ($invoke->getNumberOfParameters() < 3) {
throw new exceptions\runtime('Handler must take three arguments');
}
foreach ($arguments as $argument) {
if (self::isArgument($argument) === false) {
throw new exceptions\runtime('Argument \'' . $argument . '\' is invalid');
}
$this->handlers[$argument][] = $handler;
$this->priorities[$argument] = (int) $priority;
}
return $this;
}