_size = strlen($string); $this->_string = $string; } /** * Object destructor. */ public function __destruct() { $this->_string = ''; } /** * Returns the specified number of raw bytes from the string at the byte * offset of the current read position. * * Advances the read position by the number of bytes read. * * Throws an exception if there is insufficient data to completely fulfill * the request. * * @param integer $byteCount Number of bytes to read. * @return string * @throws Zend_Pdf_Exception */ public function readBytes($byteCount) { if (($this->_offset + $byteCount) > $this->_size) { // require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception("Insufficient data to read $byteCount bytes", Zend_Pdf_Exception::INSUFFICIENT_DATA); } $bytes = substr($this->_string, $this->_offset, $byteCount); $this->_offset += $byteCount; return $bytes; } /** * Returns the entire string. * * Preserves the current read position. * * @return string */ public function readAllBytes() { return $this->_string; } /* Object Magic Methods */ /** * Returns a string containing the parsed string's length. * * @return string */ public function __toString() { return "String ($this->_size bytes)"; } }