/** * Read elemental object from a PDF stream * * @return \Zend\Pdf\InternalType\AbstractTypeObject * @throws \Zend\Pdf\Exception */ public function readElement($nextLexeme = null) { if ($nextLexeme === null) { $nextLexeme = $this->readLexeme(); } /** * Note: readElement() method is a public method and could be invoked from other classes. * If readElement() is used not by Zend_PDF_StringParser::getObject() method, then we should not care * about _elements member management. */ switch ($nextLexeme) { case '(': return $this->_elements[] = $this->_readString(); case '<': return $this->_elements[] = $this->_readBinaryString(); case '/': return $this->_elements[] = new InternalType\NameObject(InternalType\NameObject::unescape($this->readLexeme())); case '[': return $this->_elements[] = $this->_readArray(); case '<<': return $this->_elements[] = $this->_readDictionary(); case ')': // fall through to next case // fall through to next case case '>': // fall through to next case // fall through to next case case ']': // fall through to next case // fall through to next case case '>>': // fall through to next case // fall through to next case case '{': // fall through to next case // fall through to next case case '}': throw new Pdf\Exception(sprintf('PDF file syntax error. Offset - 0x%X.', $this->offset)); default: if (strcasecmp($nextLexeme, 'true') == 0) { return $this->_elements[] = new InternalType\BooleanObject(true); } else { if (strcasecmp($nextLexeme, 'false') == 0) { return $this->_elements[] = new InternalType\BooleanObject(false); } else { if (strcasecmp($nextLexeme, 'null') == 0) { return $this->_elements[] = new InternalType\NullObject(); } } } $ref = $this->_readReference($nextLexeme); if ($ref !== null) { return $this->_elements[] = $ref; } return $this->_elements[] = $this->_readNumeric($nextLexeme); } }
public function testUnescape() { $this->assertEquals(InternalType\NameObject::unescape('My#20Cool#20Name#28#29'), 'My Cool Name()'); }