Obfuscates URI if there is an username and a password present

@param UriInterface $uri

@return UriInterface
542527
private static function obfuscateUri($uri)
    {
        $userInfo = $uri->getUserInfo();

        if (false !== ($pos = strpos($userInfo, ':'))) {
            return $uri->withUserInfo(substr($userInfo, 0, $pos), '***');
        }

        return $uri;
    }
1217686
public static function getAbsoluteUri(string $uri = null) : string
    {
        $uri = new self($uri);

        return $uri->get(false);
    }
397960
public static function isRelativePathReference(UriInterface $uri)
    {
        return $uri->getScheme() === ''
            && $uri->getAuthority() === ''
            && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/');
    }
1124028
protected function parseUri($uri)
    {
        if ($uri && stripos($uri, 'unix://') === 0) {
            // parse_url() doesn't like "unix:///foo", but parses "unix:/foo" fine.
            $uri = str_ireplace('unix://', 'unix:', $uri);
        } elseif ($uri && $uri[0] !== '/' && !preg_match('#^\w+://?.+#', $uri)) {
            // If no scheme given and path exists and isn't absolute, assume tcp scheme is wanted.
            // This allows both "127.0.0.1" and "/foo.sock" to work without specifying scheme.
            // If non absolute path is wanted, specify the scheme: "unix://foo.sock"
            $uri = 'tcp://' . $uri;
        }

        $parsed = new Uri($uri);

        return $parsed;
    }
436672
public function setBase(UriInterface $uri)
    {
        if (! $this->parser->isAbsolute($uri)) {
            throw new InvalidArgumentException('The base URI must be absolute.');
        }

        $this->base = $uri;

        return $this;
    }
243871
private function getPathWithQuery(UriInterface $uri): string
    {
        $uriString = $uri->getPath();

        if (!empty($uri->getQuery())) {
            $uriString .= self::DELIMITER_URL_QUERY . $uri->getQuery();
        }

        return $uriString;
    }
1205715
public function withUserInfo(string $username, $password = null): URI
    {
        $result = clone $this;
        $result->user = $username.((string) $password != '' ? ':'.(string) $password : '');

        return $result;
    }
117315
private function updateHostName(UriInterface $uri)
    {
        if (!$this->options['reuseHostName']) {
            return $uri;
        }
        $params = $this->request->getServerParams();
        $hasPort = !in_array($params['SERVER_PORT'], ['80', '443']);
        if ($hasPort) {
            $uri = $uri->withPort($params['SERVER_PORT']);
        }
        $isSecure = array_key_exists('HTTPS', $params) &&
            $params['HTTPS'] != strtolower('off');
        $scheme =  $isSecure ? 'https' : 'http';
        /** @var UriInterface $uri */
        $uri = $uri->withHost($params['SERVER_NAME']);
        $uri = $uri->withScheme($scheme);
        return $uri;
    }
711387
public function sanitizeUri(string $uri): string {
        if ($uri == '') {
            throw new BadMethodCallException('URI is empty');
        }
        $baseUrl = !$this->txUrl ? $this->apiUrl : $this->txUrl;
        $uri     = preg_replace('|^/|', '', $uri);
        $uri     = preg_replace('|^https?://[^/]+/rest/?(tx:[-0-9a-zA-Z]+/)?|', '', $uri);
        $uri     = $baseUrl . '/' . $uri;
        return $uri;
    }
761281
private function buildHost(UriInterface $uri): string
    {
        return $uri->getHost().($uri->getPort() !== null ? ':'.$uri->getPort() : '');
    }
586717
private function withPath(UriInterface $uri, array $server) : UriInterface {
		if (isset($server['REQUEST_URI'])) {
			return $uri->withPath(\current(\explode('?', $server['REQUEST_URI'], 2)));
		}

		return $uri;
	}
533936
public function createFromUri(UriInterface $uri)
    {
        $pointer = $uri->getFragment();
        if (null === $pointer || '/' !== substr($pointer, 0, 1)) {
            return new Pointer;
        }

        return $this->create($pointer);
    }
1009622
protected function _normalizedUrl($uri)
    {
        $out = $uri->getScheme() . '://';
        $out .= strtolower($uri->getHost());
        $out .= $uri->getPath();

        return $out;
    }
1151679
static public function removePathPrefixFromURI($uriString)
    {
        $ini = eZINI::instance();

        $prefix = self::getPathPrefix();
        if ( !$prefix )
        {
            return $uriString;
        }

        $exclude = $ini->hasVariable( 'SiteAccessSettings', 'PathPrefixExclude' )
            ? $ini->variable( 'SiteAccessSettings', 'PathPrefixExclude' )
            : false;
        foreach ( $exclude as $item )
        {
            $escapedItem = preg_quote( $item, '#' );
            if ( preg_match( "#^$escapedItem(/.*)?$#i", $uriString ) )
            {
                return $uriString;
            }
        }

        $escapedPrefix = preg_quote( $prefix, '#' );
        $modifiedUriString = preg_replace( "#^$escapedPrefix/?#i", '', $uriString );
        return $modifiedUriString === null ? $uriString : $modifiedUriString;
    }
109091
public function resolve(UriInterface $uri): UriInterface
    {
        $request = new Request('GET', $uri);
        $lastRequestUri = $request->getUri();
        $requestUri = new Uri('');

        try {
            $response = $this->httpClient->send($request, [
                'on_stats' => function (TransferStats $stats) use (&$requestUri) {
                    if ($stats->hasResponse()) {
                        $requestUri = $stats->getEffectiveUri();
                    }
                },
            ]);
        } catch (TooManyRedirectsException $tooManyRedirectsException) {
            return $requestUri;
        } catch (BadResponseException $badResponseException) {
            $response = $badResponseException->getResponse();
        }

        if ($this->followMetaRedirects) {
            $metaRedirectUri = $this->getMetaRedirectUriFromResponse($response, $lastRequestUri);

            if (!empty($metaRedirectUri) && !$this->isLastResponseUrl($metaRedirectUri, $lastRequestUri)) {
                return $this->resolve($metaRedirectUri);
            }
        }

        return $requestUri;
    }
227412
public function withRedirect(UriInterface $uri): self
    {
        $middleware = clone $this;
        $middleware->redirect = $uri;

        return $middleware;
    }
1129072
public final function withUserInfo($user, $password = null): UriInterface
   {
       return $this->with(
           "user",
           $user . ($password ? static::HOST_SEPARATOR . $password: ""));
   }