src/Url.php
public function getUrl($includeParts = self::ALL, $skipDefaultPort = true, $canonicalizePath = true) {

        if(!is_int($includeParts) || $includeParts < static::NONE || $includeParts > static::ALL) {

            throw new UrlException('Invalid part inclusion mask given.');
        }


        $return = '';

        if($includeParts & self::SCHEME && $this->scheme) {

            $return .= $this->scheme . ':';
        }

        $return .= '//';

        if($includeParts & self::USER && $this->user) {

            $return .= $this->user;

            if($includeParts & self::PASS && $this->pass) {

                $return .= ':' . $this->pass;
            }

            $return .= '@';
        }

        $return .= $this->host;

        if($includeParts & self::PORT && $this->port) {

            $defaultPort = $this->scheme ? static::getDefaultPort($this->scheme) : null;

            if($this->port !== $defaultPort || !$skipDefaultPort) {

                $return .= ':' . $this->port;
            }
        }

        if($includeParts & self::PATH && $this->path) {

            $return .= $this->getPath($canonicalizePath);
        }

        else {

            $return .= '/';
        }

        if($includeParts & self::QUERY && $this->query) {

            $return .= '?' . $this->getQueryString();
        }

        if($includeParts & self::FRAGMENT && $this->fragment) {

            $return .= '#' . $this->fragment;
        }

        return $return;
    }
public function getUrl($includeParts = self::ALL, $skipDefaultPort = true, $canonicalizePath = true) {

        if(!is_int($includeParts) || $includeParts < static::NONE || $includeParts > static::ALL) {

            throw new UrlException('Invalid part inclusion mask given.');
        }


        $return = '';

        if($includeParts & self::SCHEME && $this->scheme) {

            $return .= $this->scheme . ':';
        }

        $return .= '//';

        if($includeParts & self::USER && $this->user) {

            $return .= $this->user;

            if($includeParts & self::PASS && $this->pass) {

                $return .= ':' . $this->pass;
            }

            $return .= '@';
        }

        $return .= $this->host;

        if($includeParts & self::PORT && $this->port) {

            $defaultPort = $this->scheme ? static::getDefaultPort($this->scheme) : null;

            if($this->port !== $defaultPort || !$skipDefaultPort) {

                $return .= ':' . $this->port;
            }
        }

        if($includeParts & self::PATH && $this->path) {

            $return .= $this->getPath($canonicalizePath);
        }

        else {

            $return .= '/';
        }

        if($includeParts & self::QUERY && $this->query) {

            $return .= '?' . $this->getQueryString();
        }

        if($includeParts & self::FRAGMENT && $this->fragment) {

            $return .= '#' . $this->fragment;
        }

        return $return;
    }
@param int $includeParts
@param bool $skipDefaultPort
@param bool $canonicalizePath

@return string
@throws UrlException