public function __construct($event, $handler, $context = null, $priority = null)
{
if (is_int($context)) {
$priority = $context;
$context = null;
}
if (!is_callable($handler)) {
throw new \InvalidArgumentException('Handlers must be callable');
}
if ($context and !is_object($context)) {
throw new \InvalidArgumentException('Contexts must be objects');
}
$this->event = $event;
$this->handler = $handler;
$this->context = $context;
$this->priority = $priority;
}