With any exception from PascalCase you cannot e.g. generate class names
from strings without a explicit mapping table:
<?php
function findParserByRootNode(DomDocument $document)
{
$tagName = $document->documentElement->tagName;
$className = ucfirst($tagName) . 'Parser';
if (!class_exists($className)) {
throw new RuntimeException('Parser not found for '.$tagName);
}
return new $className();
}
$document = new DomDocument();
$document->loadXml($xml);
$parser = findParserByRootNode($document);
$parser->parse($document);
acronyms in PascalCase looks strange, but consistent strange.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php