protected function addHandler($event, callable $handler)
    {
        if (!isset($this->handlers[$event])) {
            throw new Exception("No such event '$event'");
        }

        if (!is_callable($handler)) {
            throw new Exception("Event handlers must be callable");
        }

        $this->handlers[$event][] = $handler;

        //Return last key
        return count($this->handlers[$event]) - 1;
    }
protected function addHandler($event, callable $handler)
    {
        if (!isset($this->handlers[$event])) {
            throw new Exception("No such event '$event'");
        }

        if (!is_callable($handler)) {
            throw new Exception("Event handlers must be callable");
        }

        $this->handlers[$event][] = $handler;

        //Return last key
        return count($this->handlers[$event]) - 1;
    }
protected function addHandler ( $ event , callable $ handler ) { if ( ! isset ( $ this -> handlers [ $ event ] ) ) { throw new Exception ( "No such event '$event'" ) ; } if ( ! is_callable ( $ handler ) ) { throw new Exception ( "Event handlers must be callable" ) ; } $ this -> handlers [ $ event ] [ ] = $ handler ; //Return last key return count ( $ this -> handlers [ $ event ] ) - 1 ; }
Adds a handler for the given event
@param string $event
@param callable $handler
@return int Key of the newly added handler
@throws Exception
Adds a handler for the given event