TYPO3  7.6
QpContentEncoderProxy.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of SwiftMailer.
5  * (c) 2004-2009 Chris Corbyn
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10 
19 {
23  private $safeEncoder;
24 
28  private $nativeEncoder;
29 
33  private $charset;
34 
43  {
44  $this->safeEncoder = $safeEncoder;
45  $this->nativeEncoder = $nativeEncoder;
46  $this->charset = $charset;
47  }
48 
52  public function __clone()
53  {
54  $this->safeEncoder = clone $this->safeEncoder;
55  $this->nativeEncoder = clone $this->nativeEncoder;
56  }
57 
61  public function charsetChanged($charset)
62  {
63  $this->charset = $charset;
64  }
65 
69  public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
70  {
71  $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength);
72  }
73 
77  public function getName()
78  {
79  return 'quoted-printable';
80  }
81 
85  public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
86  {
87  return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength);
88  }
89 
93  private function getEncoder()
94  {
95  return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder;
96  }
97 }