public function remove(string $key)
    {
        // check if the $key is an alias
        if (isset($this->aliases[$key])) {
            $alias = $key;
            $key = $this->aliases[$key];
            unset($this->aliases[$alias]);
        }

        // if the key exists as a factory
        if ($this->hasFactory($key)) {
            unset($this->definitions['factory'][$key]);
            $this->removeAliasFor($key);
            return ! $this->hasFactory($key);
        }

        // if the key exists as an object
        if ($this->hasObject($key)) {
            unset($this->definitions['instance'][$key], $this->store[$key]);
            $this->removeAliasFor($key);
            return ! ($this->hasObject($key) || $this->hasStored($key));
        }

        // the key did not exist
        return false;
    }