當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Swift_InputByteStream類代碼示例

本文整理匯總了PHP中Swift_InputByteStream的典型用法代碼示例。如果您正苦於以下問題:PHP Swift_InputByteStream類的具體用法?PHP Swift_InputByteStream怎麽用?PHP Swift_InputByteStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Swift_InputByteStream類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: encodeByteStream

 /**
  * Encode stream $in to stream $out.
  *
  * @param Swift_OutputByteStream $os
  * @param Swift_InputByteStream  $is
  * @param int                    $firstLineOffset
  * @param int                    $maxLineLength,  optional, 0 indicates the default of 76 bytes
  */
 public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
 {
     if (0 >= $maxLineLength || 76 < $maxLineLength) {
         $maxLineLength = 76;
     }
     $remainder = 0;
     while (false !== ($bytes = $os->read(8190))) {
         $encoded = base64_encode($bytes);
         $encodedTransformed = '';
         $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset;
         while ($thisMaxLineLength < strlen($encoded)) {
             $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength) . "\r\n";
             $firstLineOffset = 0;
             $encoded = substr($encoded, $thisMaxLineLength);
             $thisMaxLineLength = $maxLineLength;
             $remainder = 0;
         }
         if (0 < ($remainingLength = strlen($encoded))) {
             $remainder += $remainingLength;
             $encodedTransformed .= $encoded;
             $encoded = null;
         }
         $is->write($encodedTransformed);
     }
 }
開發者ID:mckshreder,項目名稱:thefootyapp_v2.0,代碼行數:33,代碼來源:Base64ContentEncoder.php

示例2: encodeByteStream

 /**
  * Encode $in to $out.
  *
  * @param Swift_OutputByteStream $os              to read from
  * @param Swift_InputByteStream  $is              to write to
  * @param integer                $firstLineOffset
  * @param integer                $maxLineLength   0 indicates the default length for this encoding
  */
 public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
 {
     $string = '';
     while (false !== ($bytes = $os->read(8192))) {
         $string .= $bytes;
     }
     $is->write($this->encodeString($string));
 }
開發者ID:rrsc,項目名稱:beansbooks,代碼行數:16,代碼來源:NativeQpContentEncoder.php

示例3: encodeByteStream

 /**
  * Encode stream $in to stream $out.
  *
  * @param Swift_OutputByteStream $os
  * @param Swift_InputByteStream  $is
  * @param int                    $firstLineOffset
  * @param int                    $maxLineLength,  optional, 0 indicates the default of 76 bytes
  */
 public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
 {
     if (0 >= $maxLineLength || 76 < $maxLineLength) {
         $maxLineLength = 76;
     }
     $remainder = 0;
     $base64ReadBufferRemainderBytes = null;
     // To reduce memory usage, the output buffer is streamed to the input buffer like so:
     //   Output Stream => base64encode => wrap line length => Input Stream
     // HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data)
     // otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream.
     // We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the
     // chunk of bytes read in the next iteration.
     // When the OutputStream is empty, we must flush any remainder bytes.
     while (true) {
         $readBytes = $os->read(8192);
         $atEOF = $readBytes === false;
         if ($atEOF) {
             $streamTheseBytes = $base64ReadBufferRemainderBytes;
         } else {
             $streamTheseBytes = $base64ReadBufferRemainderBytes . $readBytes;
         }
         $base64ReadBufferRemainderBytes = null;
         $bytesLength = strlen($streamTheseBytes);
         if ($bytesLength === 0) {
             // no data left to encode
             break;
         }
         // if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data
         // and carry over remainder 1-2 bytes to the next loop iteration
         if (!$atEOF) {
             $excessBytes = $bytesLength % 3;
             if ($excessBytes !== 0) {
                 $base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes);
                 $streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes);
             }
         }
         $encoded = base64_encode($streamTheseBytes);
         $encodedTransformed = '';
         $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset;
         while ($thisMaxLineLength < strlen($encoded)) {
             $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength) . "\r\n";
             $firstLineOffset = 0;
             $encoded = substr($encoded, $thisMaxLineLength);
             $thisMaxLineLength = $maxLineLength;
             $remainder = 0;
         }
         if (0 < ($remainingLength = strlen($encoded))) {
             $remainder += $remainingLength;
             $encodedTransformed .= $encoded;
             $encoded = null;
         }
         $is->write($encodedTransformed);
         if ($atEOF) {
             break;
         }
     }
 }
開發者ID:HaliteChallenge,項目名稱:Halite,代碼行數:66,代碼來源:Base64ContentEncoder.php

示例4: write

 /**
  * Writes $bytes to the end of the stream.
  *
  * @param string                $bytes
  * @param Swift_InputByteStream $is    optional
  */
 public function write($bytes, Swift_InputByteStream $is = null)
 {
     $this->_keyCache->setString($this->_nsKey, $this->_itemKey, $bytes, Swift_KeyCache::MODE_APPEND);
     if (isset($is)) {
         $is->write($bytes);
     }
     if (isset($this->_writeThrough)) {
         $this->_writeThrough->write($bytes);
     }
 }
開發者ID:ChrisHursty,項目名稱:bestretail,代碼行數:16,代碼來源:SimpleKeyCacheInputStream.php

示例5: encodeByteStream

 /**
  * Encode $in to $out.
  *
  * @param Swift_OutputByteStream $os              to read from
  * @param Swift_InputByteStream  $is              to write to
  * @param int                    $firstLineOffset
  * @param int                    $maxLineLength   0 indicates the default length for this encoding
  *
  * @throws RuntimeException
  */
 public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
 {
     if ($this->charset !== 'utf-8') {
         throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset));
     }
     $string = '';
     while (false !== ($bytes = $os->read(8192))) {
         $string .= $bytes;
     }
     $is->write($this->encodeString($string));
 }
開發者ID:NivalM,項目名稱:VacantesJannaMotors,代碼行數:21,代碼來源:NativeQpContentEncoder.php

示例6: encodeByteStream

 /**
  * Encode stream $in to stream $out.
  *
  * @param Swift_OutputByteStream $os
  * @param Swift_InputByteStream  $is
  * @param int                    $firstLineOffset ignored
  * @param int                    $maxLineLength   optional, 0 means no wrapping will occur
  */
 public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
 {
     $leftOver = '';
     while (false !== ($bytes = $os->read(8192))) {
         $toencode = $leftOver . $bytes;
         if ($this->_canonical) {
             $toencode = $this->_canonicalize($toencode);
         }
         $wrapped = $this->_safeWordWrap($toencode, $maxLineLength, "\r\n");
         $lastLinePos = strrpos($wrapped, "\r\n");
         $leftOver = substr($wrapped, $lastLinePos);
         $wrapped = substr($wrapped, 0, $lastLinePos);
         $is->write($wrapped);
     }
     if (strlen($leftOver)) {
         $is->write($leftOver);
     }
 }
開發者ID:musicsnap,項目名稱:Cdoco_Yaf_Ext,代碼行數:26,代碼來源:PlainContentEncoder.php

示例7: encodeByteStream

 /**
  * Encode stream $in to stream $out.
  * QP encoded strings have a maximum line length of 76 characters.
  * If the first line needs to be shorter, indicate the difference with
  * $firstLineOffset.
  * @param Swift_OutputByteStream $os output stream
  * @param Swift_InputByteStream $is input stream
  * @param int $firstLineOffset
  * @param int $maxLineLength
  */
 public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
 {
     if ($maxLineLength > 76 || $maxLineLength <= 0) {
         $maxLineLength = 76;
     }
     $thisLineLength = $maxLineLength - $firstLineOffset;
     $this->_charStream->flushContents();
     $this->_charStream->importByteStream($os);
     $currentLine = '';
     $prepend = '';
     $size = $lineLen = 0;
     while (false !== ($bytes = $this->_nextSequence())) {
         //If we're filtering the input
         if (isset($this->_filter)) {
             //If we can't filter because we need more bytes
             while ($this->_filter->shouldBuffer($bytes)) {
                 //Then collect bytes into the buffer
                 if (false === ($moreBytes = $this->_nextSequence(1))) {
                     break;
                 }
                 foreach ($moreBytes as $b) {
                     $bytes[] = $b;
                 }
             }
             //And filter them
             $bytes = $this->_filter->filter($bytes);
         }
         $enc = $this->_encodeByteSequence($bytes, $size);
         if ($currentLine && $lineLen + $size >= $thisLineLength) {
             $is->write($prepend . $this->_standardize($currentLine));
             $currentLine = '';
             $prepend = "=\r\n";
             $thisLineLength = $maxLineLength;
             $lineLen = 0;
         }
         $lineLen += $size;
         $currentLine .= $enc;
     }
     if (strlen($currentLine)) {
         $is->write($prepend . $this->_standardize($currentLine));
     }
 }
開發者ID:bigcalm,項目名稱:urlcatcher,代碼行數:52,代碼來源:QpContentEncoder.php

示例8: encodeByteStream

 /**
  * Encode stream $in to stream $out.
  *
  * @param Swift_OutputByteStream $in
  * @param Swift_InputByteStream  $out
  * @param int                    $firstLineOffset ignored
  * @param int                    $maxLineLength   ignored
  */
 public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
 {
     while (false !== ($bytes = $os->read(8192))) {
         $is->write($bytes);
     }
 }
開發者ID:ChrisHursty,項目名稱:bestretail,代碼行數:14,代碼來源:RawContentEncoder.php

示例9: exportToByteStream

 /**
  * Get data back out of the cache as a ByteStream.
  *
  * @param string                $nsKey
  * @param string                $itemKey
  * @param Swift_InputByteStream $is      to write the data to
  */
 public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is)
 {
     if ($this->hasKey($nsKey, $itemKey)) {
         $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START);
         if ($this->_quotes) {
             ini_set('magic_quotes_runtime', 0);
         }
         while (!feof($fp) && false !== ($bytes = fread($fp, 8192))) {
             $is->write($bytes);
         }
         if ($this->_quotes) {
             ini_set('magic_quotes_runtime', 1);
         }
         $this->_freeHandle($nsKey, $itemKey);
     }
 }
開發者ID:ChrisHursty,項目名稱:bestretail,代碼行數:23,代碼來源:DiskKeyCache.php

示例10: exportToByteStream

 /**
  * Get data back out of the cache as a ByteStream.
  *
  * @param string                $nsKey
  * @param string                $itemKey
  * @param Swift_InputByteStream $is      to write the data to
  */
 public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is)
 {
     $this->_prepareCache($nsKey);
     $is->write($this->getString($nsKey, $itemKey));
 }
開發者ID:Flerki,項目名稱:CarRepairTotal,代碼行數:12,代碼來源:ArrayKeyCache.php

示例11: toByteStream

 /**
  * Write this entire entity to a {@see Swift_InputByteStream}.
  *
  * @param Swift_InputByteStream
  */
 public function toByteStream(Swift_InputByteStream $is)
 {
     $is->write($this->_headers->toString());
     $is->commit();
     $this->_bodyToByteStream($is);
 }
開發者ID:Annnnnnnnnnnl,項目名稱:CodingGirlsWeb,代碼行數:11,代碼來源:SimpleMimeEntity.php

示例12: copyFromOpenSSLOutput

 /**
  * @param Swift_OutputByteStream $fromStream
  * @param Swift_InputByteStream  $toStream
  */
 protected function copyFromOpenSSLOutput(Swift_OutputByteStream $fromStream, Swift_InputByteStream $toStream)
 {
     $bufferLength = 4096;
     $filteredStream = new Swift_ByteStream_TemporaryFileByteStream();
     $filteredStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF');
     $filteredStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF');
     while (false !== ($buffer = $fromStream->read($bufferLength))) {
         $filteredStream->write($buffer);
     }
     $filteredStream->flushBuffers();
     while (false !== ($buffer = $filteredStream->read($bufferLength))) {
         $toStream->write($buffer);
     }
     $toStream->commit();
 }
開發者ID:NivalM,項目名稱:VacantesJannaMotors,代碼行數:19,代碼來源:SMimeSigner.php

示例13: toByteStream

 /**
  * Write this entire entity to a {@see Swift_InputByteStream}.
  *
  * @param Swift_InputByteStream
  */
 public function toByteStream(Swift_InputByteStream $is)
 {
     $is->write($this->_headers->toString());
     $is->commit();
     if (empty($this->_immediateChildren)) {
         if (isset($this->_body)) {
             if ($this->_cache->hasKey($this->_cacheKey, 'body')) {
                 $this->_cache->exportToByteStream($this->_cacheKey, 'body', $is);
             } else {
                 $cacheIs = $this->_cache->getInputByteStream($this->_cacheKey, 'body');
                 if ($cacheIs) {
                     $is->bind($cacheIs);
                 }
                 $is->write("\r\n");
                 if ($this->_body instanceof Swift_OutputByteStream) {
                     $this->_body->setReadPointer(0);
                     $this->_encoder->encodeByteStream($this->_body, $is, 0, $this->getMaxLineLength());
                 } else {
                     $is->write($this->_encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength()));
                 }
                 if ($cacheIs) {
                     $is->unbind($cacheIs);
                 }
             }
         }
     }
     if (!empty($this->_immediateChildren)) {
         foreach ($this->_immediateChildren as $child) {
             $is->write("\r\n\r\n--" . $this->getBoundary() . "\r\n");
             $child->toByteStream($is);
         }
         $is->write("\r\n\r\n--" . $this->getBoundary() . "--\r\n");
     }
 }
開發者ID:laiello,項目名稱:yii-mail-fix,代碼行數:39,代碼來源:SimpleMimeEntity.php


注:本文中的Swift_InputByteStream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。