Get parsed url

@param string $url Url to parse
@return array Parsed Url
502252
protected function parseUrl($url = "")
    {
        $parsed = ($url) ? parse_url($url) : parse_url($this->_env['REQUEST_URI']);
        
        if (preg_match('/[a-zA-Z0-9_]+\.php/i', $parsed['path'], $matches)) {
            $parsed['path'] = preg_replace("/$matches[0]/", '/', $parsed['path']);
        }
        
        return $parsed;
    }
1307705
protected function parseUrl(string $url)
    {
        $url = trim($url, '/');

        // Proceed if the URL is still a valid URL
        if (filter_var($url, FILTER_VALIDATE_URL)) {
            // Return an URL with a '/' if is just a domain
            return preg_match('/(\.(?<tld>\w*))$/m', $url)
                ? $url . '/'
                : $url;
        }

        throw new InvalidUrlException($url);
    }
790140
public static function getFromUrl($url)
    {
        // check is valid url
        if (!filter_var($url, FILTER_VALIDATE_URL) || !function_exists('curl_init')) {
            return null;
        }

        // initialize curl & set required options and target url
        $curl = \curl_init();
        \curl_setopt($curl, CURLOPT_URL, $url);
        if (Str::startsWith('https', $url)) {
            \curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
            \curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        }
        \curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        \curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
        \curl_setopt($curl, CURLOPT_HEADER, 0);
        \curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)');
        \curl_setopt($curl, CURLOPT_FAILONERROR, true);
        \curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        \curl_setopt($curl, CURLOPT_AUTOREFERER, true);
        \curl_setopt($curl, CURLOPT_TIMEOUT, 10);
        $content = \curl_exec($curl);
        \curl_close($curl);

        return $content;
    }
545860
public static function getParamsAsArray($url)
    {
        $query = parse_url($url, PHP_URL_QUERY);
        if (!$query) {
            return [];
        }
        $params = [];
        parse_str($query, $params);

        return $params;
    }
99661
public static function params($url) {
        $path  = explode('?', $url)[0];
        $query = parse_url($url, PHP_URL_QUERY);
        if ($query) {
            return site_url($path, $query);
        } else {
            return false;
        }
    }
1226215
public function getUriArguments($url): array
    {
        $uriParam = str_replace($url, '', $this->router->getCurrentUri());

        return array_filter(explode('/', $uriParam));
    }
1031516
public static function parse_url( $url ) {
		$r             = wp_parse_url( $url );
		$r['pathname'] = empty( $r['path'] ) ? '/' : $r['path'];
		return $r;
	}
811971
public function parse(Url $url) :? array
	{
		// Get path without possible file
		$path = $url->path();

		// Build route pattern
		$pattern = $this->buildRoutePattern();

		if (preg_match($pattern, $path, $matches) === 1) {

			$variables = [];
			$length = sizeof($matches);

			for ($i = 1; $i < $length; $i++) {
				$variables[$this->parameter[$i - 1]] = $matches[$i];
			}

			return $variables;
		}

		return null;
	}
960775
protected function processRoutes($url)
    {
        $routes = $this->config->get('routes', []);

        foreach ($routes as $from => $to) {
            $result = UrlHelper::routeParse($from, $to, $url);
            if (false !== $result && (empty($result->methods) || in_array($this->method, $result->methods, true))) {
                return $result->url;
            }
        }

        return $url;
    }
848710
public static function getHostFromUrl($url)
    {
        $parsedUrl = parse_url($url);

        if (empty($parsedUrl['host'])) {
            return;
        }

        return Common::mb_strtolower($parsedUrl['host']);
    }
351278
private function getUrl($url)
	{
		$ch = curl_init();
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_HEADER,0);
		// curl_setopt($ch, CURLOPT_ENCODING, "");
		$output = curl_exec($ch);
		curl_close($ch);
	    return $output;
	}
117939
public function getRequestUrl($url)
    {
        if ($this->getPerPage() && $this->getPage()) {
            return $url . $this->getRequestPageInfo();
        }

        return $url;
    }
540478
protected function getUrlContents(string $url): string
    {
        $request = $this->getRequest($url);

        return $this->getParsedResponse($request);
    }
424047
public static function getSubDomain($url)
    {
        $urlInfo = static::info($url);

        return ArrayHelper::get($urlInfo, 'sub', null, true);
    }
967625
public static function segmentizeUrl($url)
        {
            $url = self::normalizeUrl($url);
            $segments = explode('/', $url);

            $result = array();

            foreach ($segments as $segment) {
                if (strlen($segment)) $result[] = $segment;
            }

            return $result;
        }
845645
public static function getPath($url)
    {
        $matchFound = preg_match('/(\/v[23]\/.*$)/', $url, $matches);
        if( ! $matchFound || ! is_array($matches) || ! isset($matches[1])) {
            throw new \Exception('Unable to parse url path', 1462733286);
        }

        return $matches[1];
    }
1150909
private function processUrl($url)
    {
        $vars = [
            '{CLIENT_ID}'    => $this->getClientId(),
            '{REDIRECT_URI}' => $this->getRedirectURI(),
            '{SCOPE}'        => $this->getScope(),
            '{STATE}'        => $this->getState(),
            " "              => '',
            "\n"             => '',
            "\r"             => '',
            "\t"             => ''
        ];

        $url = str_replace(array_keys($vars), array_values($vars), $url);

        return $url;
    }