public function add($eventName, $eventHandler, $key = null) {
        if (!is_callable($eventHandler)) {
            throw new \Exception('Function is expected.');
        }

        if ($key !== null) {
            $this->{$eventName}[$key] = $eventHandler;
        }
        else {
            $this->{$eventName}[] = $eventHandler;
        }
    }
public function add($eventName, $eventHandler, $key = null) {
        if (!is_callable($eventHandler)) {
            throw new \Exception('Function is expected.');
        }

        if ($key !== null) {
            $this->{$eventName}[$key] = $eventHandler;
        }
        else {
            $this->{$eventName}[] = $eventHandler;
        }
    }
public function add ( $ eventName , $ eventHandler , $ key = null ) { if ( ! is_callable ( $ eventHandler ) ) { throw new \ Exception ( 'Function is expected.' ) ; } if ( $ key !== null ) { $ this -> { $ eventName } [ $ key ] = $ eventHandler ; } else { $ this -> { $ eventName } [ ] = $ eventHandler ; } }
Adds a handler.

@param string $eventName The event name.
@param callback $eventHandler The function of the handler.
@param string $key The unique name of the handler.

@return void
Adds a handler .