2017-07-03 17:53 GMT+02:00 Fleshgrinder <p...@fleshgrinder.com>:

> On 7/3/2017 5:30 PM, Andreas Treichel wrote:
> > 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.
> >
> >
>
> Not true in PHP because class names are not case sensitive:


While true, most applications actually depend on the case for class names
because of autoloaders.

Regards, Niklas

Reply via email to