Returns a new instance with the specified fragment.

@param string $fragment

@return URI
544140
public function withFragment(string $fragment): URI
    {
        $result = clone $this;
        $result->fragment = $this->filterFragment($fragment);

        return $result;
    }
339160
public function setFragment($fragment = null)
    {
        if (is_string($fragment)) {
            if ($fragment{0} === '#') {
                $fragment = substr($fragment, 1);
            }
        }
        else if (!is_null($fragment)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'fragment'; ".
                "expecting a string or null"
            );
        }

        $this->fragment = $fragment;
        return $this;
    }
1291782
public function getHref()
    {
        $uri = $this->getUri();
        
        $fragment = $this->getFragment();       
        if (null !== $fragment) {
            if ('#' == substr($uri, -1)) {
                return $uri . $fragment;
            } else {                
                return $uri . '#' . $fragment;
            }
        }
        
        return $uri;
    }
931459
public function withPath(string $path): UriInterface
    {
        $instance = clone $this;
        $instance->path = $this->marshalPath($path);

        return $instance;
    }
340497
public static function getInstance(array $scope = [], $options = self::ACTION_ALL)
    {
        if (!is_object(self::$instance)) {
            self::$instance = new static($scope, $options);
        }

        return self::$instance;
    }
1118263
public function withFragment(Fragment $fragment): self
    {
        $url = Structure::fromString((string) $this)->withFragment(
            new Frag((string) $fragment->substring(1))
        );

        return new self(
            (string) $url
        );
    }
128446
public function withQuery(string $query): UriInterface
    {
        $query = $this->marshalQueryAndFragment($query);

        if ( $this->query === $query ) {
            return $this;
        }

        $instance = clone $this;
        $instance->query = $query;

        return $instance;
    }
550354
public static URI setFragment(final URI path, final String fragment) {
        try {
            if (path.getPath() != null) {
                return new URI(path.getScheme(), path.getUserInfo(), path.getHost(), path.getPort(), path.getPath(), path.getQuery(), fragment);
            } else {
                return new URI(path.getScheme(), path.getSchemeSpecificPart(), fragment);
            }
        } catch (final URISyntaxException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
959439
protected function parseFragment(string $fragment = null): string
    {
        $fragment = ltrim($fragment, '#');

        return decode($fragment);
    }
766835
public <T extends Fragment> T into(T fragment) {
    fragment.setArguments(get());
    return fragment;
  }
890202
public UriComponentsBuilder fragment(String fragment) {
		if (fragment != null) {
			Assert.hasLength(fragment, "'fragment' must not be empty");
			this.fragment = fragment;
		}
		else {
			this.fragment = null;
		}
		return this;
	}
234307
public function fragment($fragment = null)
    {
        if (func_num_args() === 0) {
            return $this->_fragment;
        }
        $this->_fragment = $fragment;
        return $this;
    }
1052039
public static VolleyFragment newInstance() {
		VolleyFragment fragment = new VolleyFragment();
		Bundle args = new Bundle();

		fragment.setArguments(args);
		return fragment;
	}
2756
public function fragment($fragment)
	{
		$this->fragment = ($fragment === NULL || $fragment == '') ? NULL : (string)$fragment;
		
		return $this;
	}
819749
public static function instance($newInstance = null)
    {
        static $instance;

        if ($newInstance instanceof self) {
            $instance = $newInstance;
        }

        if (!($instance instanceof self)) {
            $instance = new self();
        }

        return $instance;
    }
1264884
public function getUrlForFragment($fragment)
    {
        $newUrl = clone $this;
        $newUrl->_fragments['fragment'] = $fragment;
        $newUrl->_inputString = $newUrl->__toString();
        return $newUrl;
    }
357511
public function internalize($url = '')
    {

        //Are we dealing with an array of parts?
        if (is_array($url)) {
            $url = implode('/', $url);
        }

        //@TODO make sure that this url does not have the scheme
        if (preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url))
            return $url;
        //@TODO make sure that this url does not have the host already
        //@TODO make sure we are internalizing a path and nothing else
        //die;
        //Do we have the path info included?
        $sPath = $this->request->getBasePath() . "/";


        if (!empty($url) && $sPath <> "/") {

            $parts = explode("/", $sPath);
            $segments = explode("/", $url);

            //Remove all empty elements
            $segments = array_filter($segments, 'strlen');
            $parts = array_filter($parts, 'strlen');
            //die;
            //This is in case we have a system deep in multiple supdirectories
            array_unshift($parts, null);
            $fragment = implode("/", $parts);

            if (is_array($segments)) {

                array_unshift($segments, null); //Adds the / to the start of the url
                $url = implode("/", $segments);

                //now look for $fragment at the start of $url
                $pos = strpos($url, $fragment);
                if ($pos !== 0 || $pos === FALSE) {
                    $url = $fragment . $url;
                }
            }
        }
        return $url;
    }