public function testUnescape() { $this->assertEquals(InternalType\NameObject::unescape('My#20Cool#20Name#28#29'), 'My Cool Name()'); }
/** * Read elemental object from a PDF stream * * @return \ZendPdf\InternalType\AbstractTypeObject * @throws \ZendPdf\Exception\ExceptionInterface */ 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. * We should care about _elements member management only if readElement() is invoked * by self::getObject() method. */ 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 Exception\CorruptedPdfException(sprintf('PDF file syntax error. Offset - 0x%X.', $this->offset)); default: if (strcasecmp($nextLexeme, 'true') == 0) { return $this->_elements[] = new InternalType\BooleanObject(true); } elseif (strcasecmp($nextLexeme, 'false') == 0) { return $this->_elements[] = new InternalType\BooleanObject(false); } elseif (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); } }