public function extend($id, callable $callback)
    {
        if (!$this->has($id)) {
            throw new Exception\NotFoundException;
        }
        $oldCallback = $this->callbacks[$id];
        $this->callbacks[$id] = function () use ($oldCallback, $callback, $id) {
            if (!$this->isReady($id)) {
                $thisFunction = $this->callbacks[$id];
                $this->callbacks[$id] = $oldCallback;
                $this->instantiate($id);
                $this->callbacks[$id] = $thisFunction;
            }
            $instance = $this->instances[$id];
            $newInstance = call_user_func($callback, $instance, $this);
            return $newInstance ?: $instance;
        };
        if ($this->isReady($id)) {
            $instance = $this->instances[$id];
            $newInstance = call_user_func($callback, $instance, $this);
            $this->instances[$id] = $newInstance ?: $instance;
        }
        return $this;
    }