@inheritdoc

@return HString

@throws \InvalidArgumentException
505093
public function filter(callable $func = null, $flag = null)
    {
        $answer = new Filter($this->toHArray());
        return new static((new HArray($answer->filter($func, $flag)))->toHString());
    }
308528
public static function createFromString($uri)
    {
        if (!is_string($uri) && !method_exists($uri, '__toString')) {
            throw new InvalidArgumentException('Uri must be a string');
        }

        return self::createFromParse(parse_url($uri));
    }
997107
public function setMode($mode)
    {
        if ($mode === null) {
            $this->mode = $mode;
            return $this;
        }

        if (!is_string($mode)) {
            throw new InvalidArgumentException(
                'Order Mode must be a string.'
            );
        }

        $mode  = strtolower($mode);
        $valid = $this->validModes();
        if (!in_array($mode, $valid)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid Order Mode. Must be one of "%s"',
                implode('", "', $valid)
            ));
        }

        if (in_array($mode, [ self::MODE_ASC, self::MODE_DESC ])) {
            $this->setDirection($mode);
        }

        $this->mode = $mode;
        return $this;
    }
817936
public static function isString($value) {
        if(is_scalar($value)) {
            return (string)$value;
        } elseif(is_object($value) && method_exists($value, '__toString')) {
            return $value->__toString();
        } else {
            throw new \InvalidArgumentException('Must be String: ' . print_r($value, true));
        }
    }
490771
public static function createFromString($url)
    {
        if (!is_string($url)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'url'; expecting a string"
            );
        }

        $ret = new Url;
        if (($url = trim($url)) === '') {
            return $ret;
        }

        if (($url = parse_url($url)) === false) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'url'; ".
                "url parsing failed"
            );
        }

        foreach ($url as $k => $v) {
            $fn = 'set'.ucfirst($k);
            call_user_func([$ret, $fn], $v);
        }
        return $ret;
    }
1133168
public function convertToString($source)
    {
        if (is_object($source)) {
            if ($source instanceof NamedInterface) {
                return $source->getName();
            } elseif (method_exists($source, '__toString')) {
                return (string) $source;
            } else {
                return get_class($source);
            }
        } elseif (is_scalar($source) || is_null($source)) {
            return (string) $source;
        } else {
            return gettype($source);
        }
    }
961767
public function nestedName($name)
    {
        if (!is_string($name)) {
            throw new InvalidArgumentException('nestedName name must string.');
        }
        $nestedTypes = $this->nestedTypes($name);

        if ($nestedTypes === false) {
            return $name;
        }
        return mb_substr($name, 0, mb_strlen($name) - mb_strlen($nestedTypes[count($nestedTypes) - 1]));
    }
322106
public function unserialize($value)
    {
        if ($value === null || is_scalar($value)) {
            $this->str = unserialize($value);
        } else {
            throw new \InvalidArgumentException(sprintf('HString cannot unserialize a %s', Helper::getType($value)));
        }
    }
915753
protected function stringOrCallback($content)
    {
        if( is_scalar($content) )
        {
            return $content;
        }
        elseif( is_callable($content) )
        {
            return Buffering\Callback::do($content);
        }

        throw new Exception\InvalidArgumentException('1.($content) parameter must be [scalar] or [callable] type!');
    }
1231882
public static function toString($numericLevel = self::NONE)
    {
        if (!is_numeric($numericLevel)) {
            throw new \InvalidArgumentException('The app type "' . $numericLevel . '" is not numeric.');
        }

        return static::nameOf($numericLevel);
    }
804488
public static function fromString($string)
    {
        $string = trim($string);
        if (!$string) {
            throw new \InvalidArgumentException('Empty attribute path');
        }

        $colonPos = strrpos($string, ':');
        if ($colonPos !== false) {
            $schema = substr($string, 0, $colonPos);
            $path = substr($string, $colonPos + 1);
        } else {
            $schema = null;
            $path = $string;
        }

        $parts = explode('.', $path);
        $attributePath = new static();
        $attributePath->schema = $schema;
        foreach ($parts as $part) {
            $attributePath->add($part);
        }

        return $attributePath;
    }
472305
protected function paramsToString() {
		$out = "";
		foreach( $this->attributes as $name => $value ) {
			$out .= " {$name}=\"{$value}\"";
		}
		return $this->standalone ? $out." /" : $out;
	}
367150
protected function resolveString($value, $method)
    {
        if (!is_scalar($value) || (is_object($value) && !method_exists($value, "__toString"))) {
            throw new InvalidArgumentException(sprintf(
                "Invalid argument given to %s, expected a string, %s given",
                $method,
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        return (string) $value;
    }
750489
public static function fromString($timeString)
    {
        try {
            return static::fromDateTime(new DateTime($timeString));
        } catch (Exception $e) {
            throw new InvalidArgumentValue('$timeString', $timeString, __CLASS__, $e);
        }
    }
367028
public function unescape(String $str) : String
    {
        if( ! is_resource($this->init) )
        {
            throw new InvalidArgumentException(NULL, '$this->init');
        }

        return curl_unescape($this->init, $str);
    }
381991
public function stringify(): string
    {
        if ($this->isConvertibleToString()) {
            return (string) $this->getValue();
        }

        if ($this->isHashable()) {
            return (string) $this->getValue()->hash();
        }

        return $this->getTypeName();
    }
341626
public function toString()
    {
        $one = $this->one->toString();
        $other = $this->other->toString();

        if ($this->one instanceof AbstractTypeConstraint) {
            $one = $this->one->isUnion() ? sprintf('(%s)', $one) : $one;
        }

        if ($this->other instanceof AbstractTypeConstraint) {
            $other = $this->other->isUnion() ? sprintf('(%s)', $other) : $other;
        }

        return sprintf('%s|%s', $one, $other);
    }