TextWrap final class
Minn\Mail\TextWrap · public/minn/src/Minn/Mail/TextWrap.php · 118 lines
Word wrapping for mail text. Lines break at spaces once they would pass the length; existing line breaks stay; a word longer than the line stays whole in plain text, and in quoted-printable text is cut into pieces ending in a soft break ("="), never inside an =XX escape or (for UTF-8) inside an encoded character. A line broken at a space keeps the space and, in quoted-printable text, a soft break after it.
Public
| static | plain(string $text, int $length, string $eol): string# | Plain text wrapped to the length, every line ending in $eol. |
| static | quotedPrintable(string $text, int $length, string $charset, string $eol): string# | Quoted-printable text wrapped to the length with soft breaks, every line ending in $eol. |
| static | utf8Boundary(string $encoded, int $max): int# | Where to cut quoted-printable UTF-8 text at or before $max without splitting an encoded character. |
Internals 5
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | wrapWith(string $text, int $length, string $softBreak, string $charset, string $eol): string# | |
| private | line(string $line, int $length, string $softBreak, string $charset, string $eol): string# | |
| private | closeLine(string $word, string $out, string $buffer, int $length, string $softBreak, string $charset, string $eol): array# | Ends the line before a long word: with as much of the word as fits when more than twenty characters are left, else with a soft break. @return array{0: string, 1: string} the output and what is left of the word |
| private | pieces(string $word, string $out, int $length, string $charset, string $eol): array# | A long word in line-length pieces, each but the last ending in a soft break. @return array{0: string, 1: string} the output and the last piece, which starts the next line |
| private | cut(string $word, int $max, string $charset): int# | How much of the word to take: at most $max, never inside an escape. |
Nothing matches.