Symfony\Component\DependencyInjection\Dumper\PhpDumper::dumpLiteralClass PHP Method

dumpLiteralClass() private method

Dumps a string to a literal (aka PHP Code) class value.
private dumpLiteralClass ( string $class ) : string
$class string
return string
    private function dumpLiteralClass($class)
    {
        if (false !== strpos($class, '$')) {
            return sprintf('${($_ = %s) && false ?: "_"}', $class);
        }
        if (0 !== strpos($class, "'") || !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
            throw new RuntimeException(sprintf('Cannot dump definition because of invalid class name (%s)', $class ?: 'n/a'));
        }

        return '\\'.substr(str_replace('\\\\', '\\', $class), 1, -1);
    }