[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/Swiftmailer/classes/Swift/Mime/ContentEncoder/ -> QpContentEncoderProxy.php (source)

   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  
  11  /**
  12   * Proxy for quoted-printable content encoders.
  13   *
  14   * Switches on the best QP encoder implementation for current charset.
  15   *
  16   * @author Jean-Fran├žois Simon <jeanfrancois.simon@sensiolabs.com>
  17   */
  18  class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder
  19  {
  20      /**
  21       * @var Swift_Mime_ContentEncoder_QpContentEncoder
  22       */
  23      private $safeEncoder;
  24  
  25      /**
  26       * @var Swift_Mime_ContentEncoder_NativeQpContentEncoder
  27       */
  28      private $nativeEncoder;
  29  
  30      /**
  31       * @var null|string
  32       */
  33      private $charset;
  34  
  35      /**
  36       * Constructor.
  37       *
  38       * @param Swift_Mime_ContentEncoder_QpContentEncoder       $safeEncoder
  39       * @param Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder
  40       * @param string|null                                      $charset
  41       */
  42      public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset)
  43      {
  44          $this->safeEncoder = $safeEncoder;
  45          $this->nativeEncoder = $nativeEncoder;
  46          $this->charset = $charset;
  47      }
  48  
  49      /**
  50       * Make a deep copy of object.
  51       */
  52      public function __clone()
  53      {
  54          $this->safeEncoder = clone $this->safeEncoder;
  55          $this->nativeEncoder = clone $this->nativeEncoder;
  56      }
  57  
  58      /**
  59       * {@inheritdoc}
  60       */
  61      public function charsetChanged($charset)
  62      {
  63          $this->charset = $charset;
  64      }
  65  
  66      /**
  67       * {@inheritdoc}
  68       */
  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  
  74      /**
  75       * {@inheritdoc}
  76       */
  77      public function getName()
  78      {
  79          return 'quoted-printable';
  80      }
  81  
  82      /**
  83       * {@inheritdoc}
  84       */
  85      public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
  86      {
  87          return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength);
  88      }
  89  
  90      /**
  91       * @return Swift_Mime_ContentEncoder
  92       */
  93      private function getEncoder()
  94      {
  95          return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder;
  96      }
  97  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1