[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/Gdata/ -> MimeBodyString.php (source)

   1  <?php
   2  
   3  /**
   4   * Zend Framework
   5   *
   6   * LICENSE
   7   *
   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 [email protected] so we can send you a copy immediately.
  15   *
  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$
  22   */
  23  
  24  /**
  25   * A wrapper for strings for buffered reading.
  26   *
  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
  32   */
  33  class Zend_Gdata_MimeBodyString
  34  {
  35  
  36      /**
  37       * The source string.
  38       *
  39       * @var string
  40       */
  41      protected $_sourceString = '';
  42  
  43      /**
  44       * The size of the MIME message.
  45       * @var integer
  46       */
  47      protected $_bytesRead = 0;
  48  
  49      /**
  50       * Create a new MimeBodyString object.
  51       *
  52       * @param string $sourceString The string we are wrapping.
  53       */
  54      public function __construct($sourceString)
  55      {
  56          $this->_sourceString = $sourceString;
  57          $this->_bytesRead = 0;
  58      }
  59  
  60      /**
  61       * Read the next chunk of the string.
  62       *
  63       * @param integer $bytesRequested The size of the chunk that is to be read.
  64       * @return string A corresponding piece of the string.
  65       */
  66      public function read($bytesRequested)
  67      {
  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;
  73        }
  74  
  75        $buffer = substr($this->_sourceString, $this->_bytesRead, $bytesRequested);
  76        $this->_bytesRead += $bytesRequested;
  77  
  78        return $buffer;
  79      }
  80  
  81      /**
  82       * The length of the string.
  83       *
  84       * @return int The length of the string contained in the object.
  85       */
  86      public function getSize()
  87      {
  88        return strlen($this->_sourceString);
  89      }
  90  
  91  
  92  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1