File indexing completed on 2024-12-22 05:36:46
0001 <?php 0002 0003 /** 0004 * Zend Framework 0005 * 0006 * LICENSE 0007 * 0008 * This source file is subject to the new BSD license that is bundled 0009 * with this package in the file LICENSE.txt. 0010 * It is also available through the world-wide-web at this URL: 0011 * http://framework.zend.com/license/new-bsd 0012 * If you did not receive a copy of the license and are unable to 0013 * obtain it through the world-wide-web, please send an email 0014 * to license@zend.com so we can send you a copy immediately. 0015 * 0016 * @category Zend 0017 * @package Zend_Gdata 0018 * @subpackage Gdata 0019 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0020 * @license http://framework.zend.com/license/new-bsd New BSD License 0021 * @version $Id$ 0022 */ 0023 0024 /** 0025 * A wrapper for strings for buffered reading. 0026 * 0027 * @category Zend 0028 * @package Zend_Gdata 0029 * @subpackage Gdata 0030 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0031 * @license http://framework.zend.com/license/new-bsd New BSD License 0032 */ 0033 class Zend_Gdata_MimeBodyString 0034 { 0035 0036 /** 0037 * The source string. 0038 * 0039 * @var string 0040 */ 0041 protected $_sourceString = ''; 0042 0043 /** 0044 * The size of the MIME message. 0045 * @var integer 0046 */ 0047 protected $_bytesRead = 0; 0048 0049 /** 0050 * Create a new MimeBodyString object. 0051 * 0052 * @param string $sourceString The string we are wrapping. 0053 */ 0054 public function __construct($sourceString) 0055 { 0056 $this->_sourceString = $sourceString; 0057 $this->_bytesRead = 0; 0058 } 0059 0060 /** 0061 * Read the next chunk of the string. 0062 * 0063 * @param integer $bytesRequested The size of the chunk that is to be read. 0064 * @return string A corresponding piece of the string. 0065 */ 0066 public function read($bytesRequested) 0067 { 0068 $len = strlen($this->_sourceString); 0069 if($this->_bytesRead == $len) { 0070 return FALSE; 0071 } else if($bytesRequested > $len - $this->_bytesRead) { 0072 $bytesRequested = $len - $this->_bytesRead; 0073 } 0074 0075 $buffer = substr($this->_sourceString, $this->_bytesRead, $bytesRequested); 0076 $this->_bytesRead += $bytesRequested; 0077 0078 return $buffer; 0079 } 0080 0081 /** 0082 * The length of the string. 0083 * 0084 * @return int The length of the string contained in the object. 0085 */ 0086 public function getSize() 0087 { 0088 return strlen($this->_sourceString); 0089 } 0090 0091 0092 }