src/Url.php
public function withFragment(?string $fragment = null): UrlInterface
    {
        if (!self::myValidateFragment($fragment, $error)) {
            throw new UrlInvalidArgumentException($error);
        }

        return new self($this->myScheme, $this->myHost, $this->myPort, $this->myPath, $this->myQueryString, $fragment);
    }
public function withFragment(?string $fragment = null): UrlInterface
    {
        if (!self::myValidateFragment($fragment, $error)) {
            throw new UrlInvalidArgumentException($error);
        }

        return new self($this->myScheme, $this->myHost, $this->myPort, $this->myPath, $this->myQueryString, $fragment);
    }
public function withFragment ( ? string $ fragment = null ) : UrlInterface { if ( ! self :: myValidateFragment ( $ fragment , $ error ) ) { throw new UrlInvalidArgumentException ( $ error ) ; } return new self ( $ this -> myScheme , $ this -> myHost , $ this -> myPort , $ this -> myPath , $ this -> myQueryString , $ fragment ) ; }
Returns a copy of the Url instance with the specified fragment.

@since 1.0.0

@param string|null $fragment The fragment or null for no fragment.

@throws UrlInvalidArgumentException If the fragment parameter is invalid.

@return UrlInterface The url instance.
Returns a copy of the Url instance with the specified fragment .