Set the fragment

@param string|null $fragment
@return \sndsgd\Url
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;
    }
370952
private function setFragment($fragment)
    {
        $this->fragment = preg_replace_callback(
            '/(?:[^' . self::$charList . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
            [$this, 'encode'],
            $fragment
        );

        return $this;
    }
1329243
private function encodeFragment($fragment)
	{
		if ( ! empty($fragment) && $fragment[0] === '#')
			$fragment = '%23' . substr($fragment, 1);

		return $this->encodeQueryOrFragment($fragment);
	}
91657
public static function getUriSegment(int $segment)
    {
        $segments = self::getUriSegments();
        return isset($segments[$segment]) ? $segments[$segment] : null;
    }
234307
public function fragment($fragment = null)
    {
        if (func_num_args() === 0) {
            return $this->_fragment;
        }
        $this->_fragment = $fragment;
        return $this;
    }
959412
public function generate($till = self :: UNTIL_FRAGMENT) {

		$url = null !== $this -> getScheme() ? $this -> getScheme() . '://' : '';

		if($till !== self :: UNTIL_SCHEME) {
			
			$url .= null !== $this -> getUser() ? $this -> getUser() . ':' : '';

			if($till !== self :: UNTIL_USER) {

				$url .= null !== $this -> getUser() ? $this -> getPassword() . '@' : '';
				
				if($till !== self :: UNTIL_PASSWORD) {

					$url .= $this -> getHost();

					if($till !== self :: UNTIL_HOST) {
						
						$url .= null !== $this -> getPath() ? $this -> getPath() : '/';

						if($till !== self :: UNTIL_PATH) {
							
							$url .= null !== $this -> getQuery() ? '?' . $this -> getQuery() : '';

							if($till !== self :: UNTIL_QUERY) {
								$url .= '#' . $this -> getFragment();						
							}
						}
					}
				}
			}
		}

		return $url;
	}
599022
public function action(String $url = NULL)
    {
        $this->settings['attr']['action'] = IS::url($url) ? $url : Request::getSiteURL($url);

        return $this;
    }
1180595
protected function filterFragment($fragment)
    {
        $fragment = preg_replace_callback(
            '/(?:[^' . self::CHARACTERS_UNRESERVED . self::CHARACTERS_SUB_DELIMS . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
            function ($match) {
                return rawurlencode($match[0]);
            },
            $fragment
        );

        if (is_null($fragment)) {
            throw new InvalidArgumentException(sprintf('Invalid fragment "%s".', $fragment));
        } elseif (!$fragment) {
            $fragment = '';
        }

        if (substr($fragment, 0, 1) === '#') {
            $fragment = substr($fragment, 1);
        }

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

        return $result;
    }
303608
private function set_fragment($ifragment)
    {
        if ($ifragment === null)
        {
            $this->ifragment = null;
        }
        else
        {
            $this->ifragment = $this->replace_invalid_with_pct_encoding($ifragment, '!$&\'()*+,;=:@/?');
            $this->scheme_normalization();
        }
        return true;
    }
959439
protected function parseFragment(string $fragment = null): string
    {
        $fragment = ltrim($fragment, '#');

        return decode($fragment);
    }
1014072
public function setFormat($format = null)
    {
        if ( ! is_null($format)) {
            self::checkFormat($format);
            $this->format = $format;
        }

        return $this;
    }
1137930
public function setSegment($segment)
    {
        if (array_key_exists($segment, $this->segments)) {
            return $this->segments[$segment];
        }
        // $reg = "#\[!--\sBEGIN\s$segment\s--\]<\/text:p>(.*?)<text:p\s.*>\[!--\sEND\s$segment\s--\]#sm";
        $reg = "#\[!--\sBEGIN\s$segment\s--\](.*?)\[!--\sEND\s$segment\s--\]#smU";
        if (preg_match($reg, html_entity_decode($this->contentXml), $m) == 0) {
            throw new OdfException("'$segment' segment not found in the document");
        }
        $this->segments[$segment] = new Segment($segment, $m[1], $this);
        return $this->segments[$segment];
    }
352958
public function setFragment($fragment)
    {
        if ($this->validateFragment($fragment) === false) {
            include_once 'Zend/Uri/Exception.php';
            throw new Zend_Uri_Exception("Fragment \"$fragment\" is not a valid HTTP fragment");
        }

        $oldFragment     = $this->_fragment;
        $this->_fragment = $fragment;

        return $oldFragment;
    }
1192317
public void setFragment(String fragment) throws URIException {
        if (fragment == null || fragment.length() == 0) {
            _fragment = (fragment == null) ? null : fragment.toCharArray();
            hash = 0;
            return;
        }
        _fragment = encode(fragment, allowed_fragment, getProtocolCharset());
        hash = 0;
    }
1214661
public function refresh($query = null, $fragment = '')
    {
        if (! isset($query)) {
            $query = $this->request->query;
        }
        return $this->redirectPath($this->request->path, $query, $fragment);
    }
1248495
public function domain($domain = null)
    {
        if (is_null($domain)) {
            return $this->getDomain();
        }

        $this->action['domain'] = $domain;

        return $this;
    }