Função de tratamento de string para formato de URL Amigavel
@param  <string> $varUrl
@return <string>
761189
public static function friendUrl($varUrl) {
        $varUrl = self::removeAcentos($varUrl);
        if (mb_detect_encoding($varUrl) == "UTF-8") {
            $varUrl = utf8_decode($varUrl);
        }
        $invalido = (array) str_split(utf8_decode("ÁáÀàÃãÂâÄäÉéÈèÊêËëÍíÌìÎîÏïÓóÒòÕõÔôÖöÚúÙùÛûÜüÇçÑñÝý& "));
        $valido = (array) str_split("AaAaAaAaAaEeEeEeEeIiIiIiIiOoOoOoOoOoUuUuUuUuCcNnYye-");
        $varUrl = strtolower(str_replace(array("-----", "----", "---", "--"), array("-", "-", "-", "-"), preg_replace("/[^A-Za-z0-9-]*/", "", str_replace($invalido, $valido, $varUrl))));

        return $varUrl;
    }
256400
public function buildUrl(string $url): string
    {
        if (filter_var($url, FILTER_VALIDATE_URL)) {
            return $url;
        }
        return $this->endPoint . static::ENDPOINT_SUFFIX . $url;
    }
893400
private function _parseUrl($url) {
    $parse = parse_url($url);
    if (empty($parse) || !is_array($parse)) {
      throw new Exception("Host is empty.");
    }

    if (!isset($parse['port']) || !$parse['port']) {
      $parse['port'] = '80';
    }

    $parse['host'] = str_replace(
        array('http://', 'https://'),
        array('', 'ssl://'),
        $parse['scheme'] . "://"
    ) . $parse['host'];

    $parse["path"] = isset($parse["path"]) ? $parse["path"] : '/';
    $query = isset($parse['query']) ? $parse['query'] : '';

    $path = str_replace(array('\\', '//'), '/', $parse['path']);
    $parse['path'] = $query ? $path . "?" . $query : $path;

    return $parse;
  }
1125400
private function createUrl(string $url): Url
    {
        $url = new Url($url);

        if ((new SchemeLess)->isSatisfiedBy($url)) {
            $url = $url->appendScheme(
                new Scheme($this->schemes[0] ?? 'http')
            );
        }

        return $url;
    }
95394
public static function trimUrl($url) {
		$result = str_replace ( "//", "/", $url );
		while ( $result !== $url ) {
			$url = $result;
			$result = str_replace ( "//", "/", $url );
		}
		return $result;
	}
881303
protected function getWebPage($url)
    {
        $curl = curl_init();

        curl_setopt($curl, CURLOPT_URL,            $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER,         false);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        $output = curl_exec($curl);
        curl_close($curl);

        return (string) $output;
    }
512712
public function convertUrl(string $url): string
    {
        $parsed = parse_url($url);
        if ($parsed === false) {
            throw new InvalidArgumentException('The given string does not look like a URL', 206);
        }

        // Nothing to do
        if ($parsed['host'] === null) {
            return $url;
        }
        $parsed['host'] = $this->convert($parsed['host']);

        return http_build_url($parsed);
    }
407020
public function queryString($url = null)
    {
        $query = '';

        if (!$url)
        {
            $url = $this->server('request_uri');
        }

        $position = mb_strpos($url, '?');

        if ($position !== false)
        {
            $query = mb_substr($url, $position + 1);
        }

        return $query;
    }
201190
private function apiUrl($url = '', $format = 'json')
    {
        if (!$url) {
            return false;
        }

        $absUrl = sprintf('https://%s/pms/v%d/%s/%s', 
                          $this->apiBase,
                          $this->version,
                          $format,
                          $url);

        return (string) $absUrl;
    }
681663
static public function formatUrl($url, $protocal=null)
	{
	    if (strpos($url, 'http') === false) {
	        $protocal || $protocal = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https://' : 'http://';
	        if (!in_array($protocal, ['http', 'https'])) {
	            $protocal = 'http';
	        }
	        
	        $url = $protocal . '://' . $url;
	        $url = str_replace(["////", "///"], "//", $url);
	    }
	    
	    return rtrim($url, '/');
	}
789087
public static function getTransformPathForUrl($url): string
    {
        /** @var ConfigModel $settings */
        $config = ImagerService::getConfig();

        $urlParts = parse_url($url);
        $pathParts = pathinfo($urlParts['path']);
        $hashRemoteUrl = $config->getSetting('hashRemoteUrl');
        $hashPath = $config->getSetting('hashPath');
        $shortHashLength = $config->getSetting('shortHashLength');
        $transformPath = $pathParts['dirname'];

        if ($hashPath) {
            $transformPath = '/' . md5($pathParts['dirname']);
        }

        if ($hashRemoteUrl) {
            if (\is_string($hashRemoteUrl) && $hashRemoteUrl === 'host') {
                $transformPath = '/' . substr(md5($urlParts['host']), 0, $shortHashLength) . $transformPath;
            } else {
                $transformPath = '/' . md5($urlParts['host'] . $pathParts['dirname']);
            }
        } else {
            $transformPath = '/' . str_replace('.', '_', $urlParts['host']) . $transformPath;
        }

        return FileHelper::normalizePath($transformPath);
    }
989552
protected function parseURL($url)
    {
        $parsed = parse_url($url);
        if ($parsed === false) {
            return false;
        } elseif (!isset($parsed['scheme']) || !$this->isValidScheme($parsed['scheme'])) {
            return false;
        } else {
            if (!isset($parsed['host']) || !$this->isValidHostName($parsed['host'])) {
                return false;
            } else {
                if (!isset($parsed['port'])) {
                    $parsed['port'] = getservbyname($parsed['scheme'], 'tcp');
                    if (!is_int($parsed['port'])) {
                        return false;
                    }
                }
            }
        }
        $parsed['custom'] = (isset($parsed['path']) ? $parsed['path'] : '/') . (isset($parsed['query']) ? '?' . $parsed['query'] : '');
        return $parsed;
    }
958548
public function createFormUrl($url)
    {
        $urlParts = parse_url($url);

        $scheme = isset($urlParts['scheme']) ? $urlParts['scheme'] : '';
        $user = isset($urlParts['user']) ? $urlParts['user'] : '';
        $password = isset($urlParts['pass']) ? $urlParts['pass'] : '';
        $host = isset($urlParts['host']) ? $urlParts['host'] : '';
        $port = isset($urlParts['port']) ? $urlParts['port'] : null;
        $path = isset($urlParts['path']) ? $urlParts['path'] : '';
        $query = isset($urlParts['query']) ? $urlParts['query'] : '';
        $fragment = isset($urlParts['fragment']) ? $urlParts['fragment'] : '';

        $this->setUri($scheme, $host, $port, $path, $query, $fragment, $user, $password);

        return $this;
    }
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;
    }
177486
protected function parseUrl($url) : string
    {
        // Ignore if its a valid url already, or an anchor link
        if (is_string($url) &&
            (filter_var($url, FILTER_VALIDATE_URL) !== false || Str::startsWith($url, '#'))) {
            return $url;
        }


        return $this->url->url($url);
    }
1039619
public function getPathFromUrl($url)
    {
        $basename = $this->storageUrl ? basename($this->storageUrl) : basename($this->storageDir);
        $basename && $url = preg_replace("/(.*$basename\/)/", '', $url);
        return $url;
    }
475216
public function generateUrl($url)
    {
        $extern = false;
        if ((0 === strrpos($url, 'http://'))
            || (0 === strrpos($url, 'https://'))) {
            $extern = true;
        }

        $http = (isset($_SERVER['HTTPS'])) ? 'https://' : 'http://';

        if (!$extern) {
            return ($this->getRoot() == '/')
                ? (($this->getRoot() == $url) ? '' : $url) : $http.$_SERVER['SERVER_NAME'].$this->getRoot().$url;
        } else {
            return $url;
        }
    }