protected function resolveType($type, string $uri, Engine $engine = null): View
    {
        $configKey = [static::VIEW_FINDER_KEY, 'Views', $type];

        if (is_string($type) && $this->config->hasKey($configKey)) {
            $className = $this->config->getKey($configKey);
            $type      = new $className($uri, $engine, $this);
        }

        if (is_string($type)) {
            $type = new $type($uri, $engine, $this);
        }

        if (is_callable($type)) {
            $type = $type($uri, $engine, $this);
        }

        if (! $type instanceof View) {
            throw new FailedToInstantiateView(
                sprintf(
                    _('Could not instantiate view "%s".'),
                    serialize($type)
                )
            );
        }

        return $type;
    }