public function withFragment(string $fragment): Uri
    {
        if ($fragment === $this->fragment) {
            return clone $this;
        }

        $fragment = $this->validateFragment($fragment);

        $new = clone $this;

        $new->fragment = $fragment;

        return $new;
    }
public function withFragment(string $fragment): Uri
    {
        if ($fragment === $this->fragment) {
            return clone $this;
        }

        $fragment = $this->validateFragment($fragment);

        $new = clone $this;

        $new->fragment = $fragment;

        return $new;
    }
public function withFragment ( string $ fragment ) : Uri { if ( $ fragment === $ this -> fragment ) { return clone $ this ; } $ fragment = $ this -> validateFragment ( $ fragment ) ; $ new = clone $ this ; $ new -> fragment = $ fragment ; return $ new ; }
Return an instance with the specified URI fragment.

This method MUST retain the state of the current instance, and return
an instance that contains the specified URI fragment.

Users can provide both encoded and decoded fragment characters.
Implementations ensure the correct encoding as outlined in getFragment().

An empty fragment value is equivalent to removing the fragment.

@param string $fragment The fragment to use with the new instance.

@return static A new instance with the specified fragment.
Return an instance with the specified URI fragment .