Fix line length

@override To wrap by must length by default.

@param string $message Message to wrap
@param int $wrapLength
@return array Wrapped message
769022
protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) {
		if ($this->_wrapLength !== null) {
			$wrapLength = $this->_wrapLength;
		}
		return parent::_wrap($message, $wrapLength);
	}
1195148
public static function unwrap(string $text, string $wrappers) : string
    {
        $size = strlen($wrappers);
        for ($i = 0; $i < $size; $i += 2) {
            if (substr($text, 0, 1) == substr($wrappers, $i, 1)
               && substr($text, -1) == substr($wrappers, $i + 1, 1))
                return substr($text, 1, strlen($text) - 2);
        }
        return $text;
    }
1264360
private static String wrapLine(String str, int wrapTextLength) {
	int wtl = wrapTextLength;

	if (str.length() <= wtl) return str;

	String sub = str.substring(0, wtl);
	String rest = str.substring(wtl);
	char firstR = rest.charAt(0);
	String ls = SystemUtil.getOSSpecificLineSeparator();

	if (firstR == ' ' || firstR == '\t') return sub + ls + wrapLine(rest.length() > 1 ? rest.substring(1) : "", wrapTextLength);

	int indexSpace = sub.lastIndexOf(' ');
	int indexTab = sub.lastIndexOf('\t');
	int index = indexSpace <= indexTab ? indexTab : indexSpace;

	if (index == -1) return sub + ls + wrapLine(rest, wrapTextLength);
	return sub.substring(0, index) + ls + wrapLine(sub.substring(index + 1) + rest, wrapTextLength);

    }
1000352
public function setWrapWidth(float $wrapwidth, float $cellwidth): float
    {
        $this->wrapWidthCell = $cellwidth;
        if (strpos($this->text, "\n") !== false) {
            $this->wrapWidthRemaining = $cellwidth;
        } else {
            $this->wrapWidthRemaining = $wrapwidth;
        }

        return $this->wrapWidthRemaining;
    }
891950
public function validate(Message $message)
    {
        if ($message->getBodyWrapLength() > self::WRAP_LIMIT) {
            $message->addStatus(new LimitTheBodyWrapLengthTo72CharactersStatus());
        }
    }
25125
public function asSecret(StringLength $length = null)
    {
        return $this->handleFilter(
                function() use($length)
                {
                    return filter\RangeFilter::wrap(
                            filter\SecretFilter::instance(),
                            $length
                    );
                }
        );
    }
492351
def wrap (text, width, **kwargs):
    """"""
    if width <= 0 or not text:
        return text
    ret = []
    for para in get_paragraphs(text):
        text = " ".join(para.strip().split())
        ret.extend(textwrap.wrap(text, width, **kwargs))
    return os.linesep.join(ret)
267156
public static function repeatToLength($string, $length, $cut = false)
    {
        if (strlen($string) >= $length) {
            return $string;
        }

        $string = str_repeat($string, (int) ceil($length / strlen($string)));

        if ($cut) {
            $string = substr($string, 0, $length);
        }

        return $string;
    }
682881
private function safeWordwrap($string, $length = 75, $le = "\r\n")
    {
        if (0 >= $length) {
            return $string;
        }

        $originalLines = explode($le, $string);

        $lines = [];
        $lineCount = 0;

        foreach ($originalLines as $originalLine) {
            $lines[] = '';
            $currentLine = &$lines[$lineCount++];

            //$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine);
            $chunks = preg_split('/(?<=\s)/', $originalLine);

            foreach ($chunks as $chunk) {
                if (0 != strlen($currentLine)
                    && strlen($currentLine.$chunk) > $length) {
                    $lines[] = '';
                    $currentLine = &$lines[$lineCount++];
                }
                $currentLine .= $chunk;
            }
        }

        return implode("\r\n", $lines);
    }
668161
public static function wrap(string $text, int $length, string $separator = "\n"): string
    {
        if ($text === '' || self::length($text) === $length) {
            return $text;
        }
        $endedWithLinebreak = substr($text, -1) === "\n";
        $text = str_replace("\r", '', $text);
        $text = str_replace("\n", '', $text);
        $text = explode(' ', $text);

        $result = [];
        $lineNo = 0;
        foreach ($text as $word) {
            if (!isset($result[$lineNo])) {
                $result[$lineNo] = '';
            }
            $lastLineNo = count($result) - 1;

            if ((self::length($result[$lastLineNo]) + self::length($word)) >= $length) {
                $lineNo++;
                if (!isset($result[$lineNo])) {
                    $result[$lineNo] = '';
                }
                $lastLineNo = count($result) - 1;
            }

            $result[$lastLineNo] .= $result[$lastLineNo] !== '' ? ' ' : '';
            $result[$lastLineNo] .= $word;
        }

        $text = implode($separator, $result);
        if ($endedWithLinebreak) {
            $text .= "\n";
        }
        return $text;
    }
342373
public static String fixLength(final String text, final int charsNum, final char paddingChar)
    {
        return fixLength(text, charsNum, paddingChar, false);
    }
800999
public static function wrap($comment, $format, $width = 80)
    {
        $result = array();
        $width = $width - self::getWidth($format);
        // collect lines
        $lines = array();
        foreach (explode("\n", $comment) as $line) {
            foreach (explode("\n", wordwrap($line, $width, "\n")) as $sline) {
                $lines[] = $sline;
            }
        }
        // write lines
        $no = 0;
        $count = count($lines);
        foreach ($lines as $line) {
            $no++;
            self::getLine($no, $count, $format, $line, $result);
        }

        return $result;
    }
892715
public function setLength($length)
    {
        $this->length = $length;
        if ($this->length !== null && $this->length < 0) {
            throw new BuildException('Cannot truncate to length ' . $this->length);
        }
    }
1212165
public function wrapWords( $maxLineLength = 76 )
	{
		$this->content	= chunk_split( $this->content, $maxLineLength, Net_Mail::$delimiter );
	}
137053
def _wrap(self, line: str) -> str:
        
        wrap_mode = self.config['multi_line_output']
        if len(line) > self.config['line_length'] and wrap_mode != WrapModes.NOQA:
            line_without_comment = line
            comment = None
            if '#' in line:
                line_without_comment, comment = line.split('#', 1)
            for splitter in ("import ", ".", "as "):
                exp = r"\b" + re.escape(splitter) + r"\b"
                if re.search(exp, line_without_comment) and not line_without_comment.strip().startswith(splitter):
                    line_parts = re.split(exp, line_without_comment)
                    if comment:
                        line_parts[-1] = '{0}#{1}'.format(line_parts[-1], comment)
                    next_line = []
                    while (len(line) + 2) > (self.config['wrap_length'] or self.config['line_length']) and line_parts:
                        next_line.append(line_parts.pop())
                        line = splitter.join(line_parts)
                    if not line:
                        line = next_line.pop()

                    cont_line = self._wrap(self.config['indent'] + splitter.join(next_line).lstrip())
                    if self.config['use_parentheses']:
                        output = "{0}{1}({2}{3}{4}{5})".format(
                            line, splitter, self.line_separator, cont_line,
                            "," if self.config['include_trailing_comma'] else "",
                            self.line_separator if wrap_mode in {WrapModes.VERTICAL_HANGING_INDENT,
                                                                 WrapModes.VERTICAL_GRID_GROUPED}
                            else "")
                        lines = output.split(self.line_separator)
                        if self.config['comment_prefix'] in lines[-1] and lines[-1].endswith(')'):
                            line, comment = lines[-1].split(self.config['comment_prefix'], 1)
                            lines[-1] = line + ')' + self.config['comment_prefix'] + comment[:-1]
                        return self.line_separator.join(lines)
                    return "{0}{1}\\{2}{3}".format(line, splitter, self.line_separator, cont_line)
        elif len(line) > self.config['line_length'] and wrap_mode == settings.WrapModes.NOQA:
            if "# NOQA" not in line:
                return "{0}{1} NOQA".format(line, self.config['comment_prefix'])

        return line
1210909
public function hasMinLength($minLength)
    {
        $this->isString();

        $this->doCheck(function ($value) use ($minLength) {
            $this->throwExceptionIfFalse(
                mb_strlen($value) >= $minLength,
                'Failed assertion that %s has at least %s characters', $value, $minLength
            );
        });

        return $this;
    }
1233149
public function getMessageLines($text)
    {
        $message = $text;
        $wrapLength = 40;
        // wrap the message to max chars
        $message = wordwrap($message, $wrapLength - 2);
        // split into array of lines
        return explode("\n", $message);
    }