public static function root($addAuth = false)
    {
        $url = '';

        // Check to see if it's over https
        $isHttps = self::isHttps();

        // Was a username or password passed?
        if ($addAuth) {
            $url .= self::getAuth();
        }

        $serverData = data($_SERVER);

        // We want the user to stay on the same host they are currently on,
        // but beware of security issues
        // see http://shiflett.org/blog/2006/mar/server-name-versus-http-host
        $host = $serverData->get('HTTP_HOST');
        $port = (int)$serverData->get('SERVER_PORT');
        $url .= str_replace(':' . $port, '', $host);

        // Is it on a non standard port?
        if ($isHttps && $port !== self::PORT_HTTPS) {
            $url .= $port ? ":{$port}" : '';
        } elseif (!$isHttps && $port !== self::PORT_HTTP) {
            $url .= $port ? ":{$port}" : '';
        }

        if ($url) {
            if ($isHttps) {
                return 'https://' . $url;
            }
            return 'http://' . $url;
        }

        return null;
    }
public static function root($addAuth = false)
    {
        $url = '';

        // Check to see if it's over https
        $isHttps = self::isHttps();

        // Was a username or password passed?
        if ($addAuth) {
            $url .= self::getAuth();
        }

        $serverData = data($_SERVER);

        // We want the user to stay on the same host they are currently on,
        // but beware of security issues
        // see http://shiflett.org/blog/2006/mar/server-name-versus-http-host
        $host = $serverData->get('HTTP_HOST');
        $port = (int)$serverData->get('SERVER_PORT');
        $url .= str_replace(':' . $port, '', $host);

        // Is it on a non standard port?
        if ($isHttps && $port !== self::PORT_HTTPS) {
            $url .= $port ? ":{$port}" : '';
        } elseif (!$isHttps && $port !== self::PORT_HTTP) {
            $url .= $port ? ":{$port}" : '';
        }

        if ($url) {
            if ($isHttps) {
                return 'https://' . $url;
            }
            return 'http://' . $url;
        }

        return null;
    }
public static function root ( $ addAuth = false ) { $ url = '' ; // Check to see if it's over https $ isHttps = self :: isHttps ( ) ; // Was a username or password passed? if ( $ addAuth ) { $ url .= self :: getAuth ( ) ; } $ serverData = data ( $ _SERVER ) ; // We want the user to stay on the same host they are currently on, // but beware of security issues // see http://shiflett.org/blog/2006/mar/server-name-versus-http-host $ host = $ serverData -> get ( 'HTTP_HOST' ) ; $ port = ( int ) $ serverData -> get ( 'SERVER_PORT' ) ; $ url .= str_replace ( ':' . $ port , '' , $ host ) ; // Is it on a non standard port? if ( $ isHttps && $ port !== self :: PORT_HTTPS ) { $ url .= $ port ? ":{$port}" : '' ; } elseif ( ! $ isHttps && $ port !== self :: PORT_HTTP ) { $ url .= $ port ? ":{$port}" : '' ; } if ( $ url ) { if ( $ isHttps ) { return 'https://' . $ url ; } return 'http://' . $ url ; } return null ; }
Return current root URL

@param bool $addAuth
@return null|string

@SuppressWarnings(PHPMD.Superglobals)
Return current root URL