1: <?php
2:
3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16:
17: class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_ContentEncoder
18: {
19: 20: 21: 22: 23: 24: 25:
26: public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
27: {
28: if (0 >= $maxLineLength || 76 < $maxLineLength) {
29: $maxLineLength = 76;
30: }
31:
32: $remainder = 0;
33:
34: while (false !== $bytes = $os->read(8190)) {
35: $encoded = base64_encode($bytes);
36: $encodedTransformed = '';
37: $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset;
38:
39: while ($thisMaxLineLength < strlen($encoded)) {
40: $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength) . "\r\n";
41: $firstLineOffset = 0;
42: $encoded = substr($encoded, $thisMaxLineLength);
43: $thisMaxLineLength = $maxLineLength;
44: $remainder = 0;
45: }
46:
47: if (0 < $remainingLength = strlen($encoded)) {
48: $remainder += $remainingLength;
49: $encodedTransformed .= $encoded;
50: $encoded = null;
51: }
52:
53: $is->write($encodedTransformed);
54: }
55: }
56:
57: 58: 59: 60: 61:
62: public function getName()
63: {
64: return 'base64';
65: }
66: }
67: