/** * Parses a control symbol token * * @param Jstewnc\Rtf\Token\Control\Symbol $token the control symbol token * @param Jstewmc\Rtf\Element\Group $group the current group * @return void * @since 0.1.0 */ protected function parseControlSymbol(Token\Control\Symbol $token, Element\Group $group) { // if a class exists for the symbol, instantiate it; otherwise, instantiate // a generic control symbol element // keep in mind, class_exists() requires a fully-qualified namespace // if (array_key_exists($token->getSymbol(), self::$symbols)) { // get the symbol's name $name = self::$symbols[$token->getSymbol()]; $name = ucfirst($name); $classname = "Jstewmc\\Rtf\\Element\\Control\\Symbol\\{$name}"; if (class_exists($classname)) { $symbol = new $classname(); } else { $symbol = new Element\Control\Symbol\Symbol(); $symbol->setSymbol($token->getSymbol()); } } else { $symbol = new Element\Control\Symbol\Symbol(); $symbol->setSymbol($token->getSymbol()); } // set the symbol's parameter $symbol->setParameter($token->getParameter()); $symbol->setIsSpaceDelimited($token->getIsSpaceDelimited()); // append the element $symbol->setParent($group); $group->appendChild($symbol); return; }