[ Index ]

MailPress 7.2

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

title

Body

[close]

/mp-includes/composer/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/ -> Base64Encoder.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   * Handles Base 64 Encoding in Swift Mailer.
  13   *
  14   * @author Chris Corbyn
  15   */
  16  class Swift_Encoder_Base64Encoder implements Swift_Encoder
  17  {
  18      /**
  19       * Takes an unencoded string and produces a Base64 encoded string from it.
  20       *
  21       * Base64 encoded strings have a maximum line length of 76 characters.
  22       * If the first line needs to be shorter, indicate the difference with
  23       * $firstLineOffset.
  24       *
  25       * @param string $string          to encode
  26       * @param int    $firstLineOffset
  27       * @param int    $maxLineLength   optional, 0 indicates the default of 76 bytes
  28       *
  29       * @return string
  30       */
  31      public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
  32      {
  33          if (0 >= $maxLineLength || 76 < $maxLineLength) {
  34              $maxLineLength = 76;
  35          }
  36  
  37          $encodedString = base64_encode($string);
  38          $firstLine = '';
  39  
  40          if (0 != $firstLineOffset) {
  41              $firstLine = substr(
  42                  $encodedString, 0, $maxLineLength - $firstLineOffset
  43                  )."\r\n";
  44              $encodedString = substr(
  45                  $encodedString, $maxLineLength - $firstLineOffset
  46                  );
  47          }
  48  
  49          return $firstLine.trim(chunk_split($encodedString, $maxLineLength, "\r\n"));
  50      }
  51  
  52      /**
  53       * Does nothing.
  54       */
  55      public function charsetChanged($charset)
  56      {
  57      }
  58  }


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1