public static function compress(string $value = null, bool $replaceVerticalWhitespace = false)
    {
        if ($value === null) {
            return null;
        }

        $pattern = $replaceVerticalWhitespace ? '\s+' : '\h+';

        return trim(preg_replace("/{$pattern}/", ' ', $value));
    }
public static function compress(string $value = null, bool $replaceVerticalWhitespace = false)
    {
        if ($value === null) {
            return null;
        }

        $pattern = $replaceVerticalWhitespace ? '\s+' : '\h+';

        return trim(preg_replace("/{$pattern}/", ' ', $value));
    }
public static function compress ( string $ value = null , bool $ replaceVerticalWhitespace = false ) { if ( $ value === null ) { return null ; } $ pattern = $ replaceVerticalWhitespace ? '\s+' : '\h+' ; return trim ( preg_replace ( "/{$pattern}/" , ' ' , $ value ) ) ; }
This filter trims and removes superfluous whitespace characters from the given string.

@param string|null $value                     The string to compress.
@param bool        $replaceVerticalWhitespace Flag to replace vertical whitespace such as newlines with
single space.

@return string|null
This filter trims and removes superfluous whitespace characters from the given string .