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;
        }
    }