[ZF-10089] Zend_Log
[zend/radio.git] / library / Zend / Gdata / MimeBodyString.php
blobc8230b17578f21bdc21b9d1db1aaf070fc4ff3a4
1 <?php
3 /**
4 * Zend Framework
6 * LICENSE
8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
16 * @category Zend
17 * @package Zend_Gdata
18 * @subpackage Gdata
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 * @version $Id$
24 /**
25 * A wrapper for strings for buffered reading.
27 * @category Zend
28 * @package Zend_Gdata
29 * @subpackage Gdata
30 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
31 * @license http://framework.zend.com/license/new-bsd New BSD License
33 class Zend_Gdata_MimeBodyString
36 /**
37 * The source string.
39 * @var string
41 protected $_sourceString = '';
43 /**
44 * The size of the MIME message.
45 * @var integer
47 protected $_bytesRead = 0;
49 /**
50 * Create a new MimeBodyString object.
52 * @param string $sourceString The string we are wrapping.
54 public function __construct($sourceString)
56 $this->_sourceString = $sourceString;
57 $this->_bytesRead = 0;
60 /**
61 * Read the next chunk of the string.
63 * @param integer $bytesRequested The size of the chunk that is to be read.
64 * @return string A corresponding piece of the string.
66 public function read($bytesRequested)
68 $len = strlen($this->_sourceString);
69 if($this->_bytesRead == $len) {
70 return FALSE;
71 } else if($bytesRequested > $len - $this->_bytesRead) {
72 $bytesRequested = $len - $this->_bytesRead;
75 $buffer = substr($this->_sourceString, $this->_bytesRead, $bytesRequested);
76 $this->_bytesRead += $bytesRequested;
78 return $buffer;
81 /**
82 * The length of the string.
84 * @return int The length of the string contained in the object.
86 public function getSize()
88 return strlen($this->_sourceString);