private static function getFactory(string $type)
    {
        if (!empty(self::$factories[$type])) {
            return self::$factories[$type];
        }

        if (!empty(self::$factory)) {
            return self::$factories[$type] = self::$factory;
        }

        foreach (self::$strategies as $className) {
            if (is_array($className) && isset($className[$type])) {
                $className = $className[$type];

                if (class_exists($className)) {
                    return self::$factories[$type] = new $className();
                }

                continue;
            }

            if (!class_exists($className)) {
                continue;
            }

            if (strpos($className, __NAMESPACE__) === 0 && !$className::isInstalled()) {
                continue;
            }

            return self::$factories[$type] = self::$factory = new $className();
        }

        throw new RuntimeException('No PSR-7 library detected');
    }