private function build(string $name)
    {
        $instance = null;
        $map = $this->map[$name];

        if (is_array($map)) {
            $params = $this->getParamsFromMap($map);
            $instance = new $name(...$params);
        } elseif ($map instanceof \Closure) {
            $instance = $map($this);
        } elseif (is_object($map)) {
            $instance = $map;
        } elseif (is_string($map)) {
            $instance = $this->get($map);
        } else {
            throw new \Exception('Invalid map');
        }

        return $instance;
    }