lib/FileWrapper.php
protected function textwordwrap($content): string
    {
        $tmp = explode("\n", $content);
        $currmax = 0;
        foreach ($tmp as $line) {
            if (function_exists('mb_strlen')) {
                $lw = mb_strlen($line);
                if ($lw === false) {
                    $lw = strlen($line);
                }
            } else {
                $lw = strlen($line);
            }
            if ($lw > $currmax) {
                $currmax = $lw;
            }
        }
        if ($currmax > 120) {
            $n = count($tmp);
            for ($i=0; $i<$n; $i++) {
                if (function_exists('mbWordWrap')) {
                    $tmp[$i] = mbWordWrap($tmp[$i], 80, "\n", true);
                } elseif (function_exists('mb_strlen')) {
                    $tmp[$i] = $this->mbWordWrap($tmp[$i], 80, "\n", true);
                } else {
                    $tmp[$i] = wordwrap($tmp[$i], 80, "\n", true);
                }
            }
            $content = implode("\n", $tmp);
        }
        return $content;
    }
protected function textwordwrap($content): string
    {
        $tmp = explode("\n", $content);
        $currmax = 0;
        foreach ($tmp as $line) {
            if (function_exists('mb_strlen')) {
                $lw = mb_strlen($line);
                if ($lw === false) {
                    $lw = strlen($line);
                }
            } else {
                $lw = strlen($line);
            }
            if ($lw > $currmax) {
                $currmax = $lw;
            }
        }
        if ($currmax > 120) {
            $n = count($tmp);
            for ($i=0; $i<$n; $i++) {
                if (function_exists('mbWordWrap')) {
                    $tmp[$i] = mbWordWrap($tmp[$i], 80, "\n", true);
                } elseif (function_exists('mb_strlen')) {
                    $tmp[$i] = $this->mbWordWrap($tmp[$i], 80, "\n", true);
                } else {
                    $tmp[$i] = wordwrap($tmp[$i], 80, "\n", true);
                }
            }
            $content = implode("\n", $tmp);
        }
        return $content;
    }
Word Wrap text files. Turned off by default, extend class to use.

@param string $content The content to be word wrapped.

@return string The word wrapped content.