src/Header.php
public static function wrap($header, $width = 0)
    {
        if ($width <= 0) {
            return $header;
        }
        $result = [];
        $lineLength = 0;
        $parts = preg_split('~\s+~', $header);

        while ($current = current($parts))
        {
            $next = next($parts);
            $lineLength += strlen($current);
            if ($next && ($lineLength + strlen($next)) > ($width - 1)) {
                $result[] = $current . Headers::EOL;
                $lineLength = 0;
            } else {
                $result[] = $current;
            }
        }
        return join(' ', $result);
    }
public static function wrap($header, $width = 0)
    {
        if ($width <= 0) {
            return $header;
        }
        $result = [];
        $lineLength = 0;
        $parts = preg_split('~\s+~', $header);

        while ($current = current($parts))
        {
            $next = next($parts);
            $lineLength += strlen($current);
            if ($next && ($lineLength + strlen($next)) > ($width - 1)) {
                $result[] = $current . Headers::EOL;
                $lineLength = 0;
            } else {
                $result[] = $current;
            }
        }
        return join(' ', $result);
    }
public static function wrap ( $ header , $ width = 0 ) { if ( $ width <= 0 ) { return $ header ; } $ result = [ ] ; $ lineLength = 0 ; $ parts = preg_split ( '~\s+~' , $ header ) ; while ( $ current = current ( $ parts ) ) { $ next = next ( $ parts ) ; $ lineLength += strlen ( $ current ) ; if ( $ next && ( $ lineLength + strlen ( $ next ) ) > ( $ width - 1 ) ) { $ result [ ] = $ current . Headers :: EOL ; $ lineLength = 0 ; } else { $ result [ ] = $ current ; } } return join ( ' ' , $ result ) ; }
Fold a header entry

@param string $header The header to fold.
Fold a header entry