Phan\Language\FQSEN\FullyQualifiedGlobalStructuralElement::cleanNamespace PHP Méthode

cleanNamespace() protected static méthode

protected static cleanNamespace ( string $namespace ) : string
$namespace string
Résultat string A cleaned version of the given namespace such that its always prefixed with a '\' and never ends in a '\', and is the string "\" if there is no namespace.
    protected static function cleanNamespace(string $namespace) : string
    {
        if (!$namespace || empty($namespace) || $namespace === '\\') {
            return '\\';
        }
        // Ensure that the first character of the namespace
        // is always a '\'
        if (0 !== strpos($namespace, '\\')) {
            $namespace = '\\' . $namespace;
        }
        // Ensure that we don't have a trailing '\' on the
        // namespace
        if ('\\' === substr($namespace, -1)) {
            $namespace = substr($namespace, 0, -1);
        }
        return $namespace;
    }