Get namespace part of a class name.

@param string|object $className
Class or object, e.g. 'Jivoo\Utilities'.
@return string Namespace, e.g. 'Jivoo'.
192469
public static function getNamespace($className)
    {
        if (is_object($className)) {
            $className = get_class($className);
        }
        if (strpos($className, '\\') === false) {
            return '';
        }
        return preg_replace('/\\\\[^\\\\]+$/', '', $className);
    }
283333
private function namespaceFromLegacyNamespace($namespace, $className)
    {
        $qcn = str_replace('_', '\\', $className);

        $lastBackslash = strrpos($qcn, '\\');
        if ($lastBackslash) {
            $namespace = rtrim($namespace, '\\') . '\\' . substr($qcn, 0, $lastBackslash);
        }

        return $namespace;
    }
79300
public function getProxyClassName($className)
    {
        $suffix = ltrim($className, '\\');
        
        if ($this->proxyClassSuffix !== null) {
            $suffix .= $this->proxyClassSuffix;    
        }
        
        return rtrim($this->proxyNamespace, '\\') . '\\'.self::MARKER.'\\' . $suffix;
    }
950406
public function get_namespace($name = null)
    {
        $ns = $this->namespace;

        if ($name) {
            // an alias for BC
            if ($name == 'prefix') {
                $name = 'prefix_in';
            }

            return isset($ns[$name]) ? $ns[$name] : null;
        }

        unset($ns['prefix_in'], $ns['prefix_out']);

        return $ns;
    }
438016
protected function getClassShortName(?string $className = null): string
	{
		$class = $className ?? static::class;

		$pos = strrpos($class, '\\');

		if($pos === false)
		{
			return $class;
		}

		return substr($class, $pos + 1);
	}
521532
public function resolveFileName($className)
    {
        if (
            null === $this->getNamespace() ||
            $this->getNamespace().$this->getNamespaceSeparator() === substr($className, 0, strlen($this->getNamespace().$this->getNamespaceSeparator()))
        ) {
            $fileName   = '';
            $namespace  = '';
            if (false !== ($lastNsPos = strripos($className, $this->getNamespaceSeparator()))) {
                $namespace  = substr($className, 0, $lastNsPos);
                $className  = substr($className, $lastNsPos + 1);
                $fileName   = str_replace($this->getNamespaceSeparator(), DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
            }
            $fileName  .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->getFileExtension();
            return ($this->getIncludePath() !== null ? $this->getIncludePath() . DIRECTORY_SEPARATOR : '') . $fileName;
        }
        return null;
    }
947882
protected function getNamespace($name)
    {
        $name = explode('\\', $name);
        
        unset($name[(count($name) - 1)]);

        $nameSpace = implode('\\', $name);

        return trim($nameSpace);
    }
58410
public static function getClassName($className)
    {
        if (is_object($className)) {
            $className = get_class($className);
        }
        $className = array_slice(explode('\\', $className), - 1);
        return $className[0];
    }
1249219
public function getIdentifier($namespace)
    {
        $namespace = Str::normalizeClassName($namespace);
        if (strpos($namespace, '\\') === null) {
            return $namespace;
        }

        $parts = explode('\\', $namespace);
        $slice = array_slice($parts, 1, 2);
        $namespace = implode('.', $slice);

        return $namespace;
    }
1258433
public function classname_to_path( $classname ) {
		// Convert the namespace to a sub-directory path
		if ( strpos( $classname, '\\' ) !== false) {
			$classname = str_replace( '\\', DIRECTORY_SEPARATOR, $classname );
		}

		return $classname;
	}
974002
public static function getStorageKey($className)
    {
        $key = $className;

        if (!\OxidEsales\Eshop\Core\NamespaceInformationProvider::isNamespacedClass($className)) {
            $bcMap = self::getBackwardsCompatibilityClassMap();
            $key = isset($bcMap[strtolower($key)]) ? $bcMap[strtolower($key)] : strtolower($key);
        }

        return $key;
    }
634424
public static function getNamespace($class)
    {
        if (is_object($class) === true) {
            $class = get_class($class);
        }
        foreach (['\\', '_'] as $separator) {
            $pos = strrpos($class, $separator);
            if ($pos !== false) {
                return ltrim(substr($class, 0, $pos), $separator);
            }
        }
        return '';
    }
1058199
private function getTableNamePrefix($className)
    {
        $name = ltrim($className, '\\');
        foreach ($this->namingMap as $prefix => $namespace) {
            if (strpos($name, $namespace) === 0) {
                return $prefix . '_';
            }
        }

        return '';
    }
1305022
public function getDescriptor(string $classNamespace): ?Descriptor
    {
        if (!$this->isEmpty()) {
            /** @var Descriptor $descriptor */
            foreach ($this as $rootNamespace => $descriptor) {
                $rootNamespace = $descriptor->getRootNamespace();

                $doubleSlashed = str_replace('\\', '\\\\', $rootNamespace);
                $pattern = sprintf('|^%s\\.*|', $doubleSlashed);

                if (preg_match($pattern, $classNamespace)) {
                    return $descriptor;
                }
            }
        }

        return null;
    }
723926
private function getNewEmbeddableFqnFromClassName(string $className): string
    {
        return $this->namespaceHelper->tidy(
            $this->projectRootNamespace . '\\'
            . implode('\\', \array_slice($this->archetypeObjectSubDirectories, 1))
            . '\\' . $className
        );
    }
370571
public function load($className)
    {
        $this->_classFilename = $className . '.php';
        $this->_includePaths  = explode(PATH_SEPARATOR, get_include_path());
        $classFound           = null;

        if(strpos($this->_classFilename, '\\') !== false)
        {
            $classFound = $this->searchForBackslashNamespacedClass();
        }
        elseif(strpos($this->_classFilename, '_') !== false)
        {
            $classFound = $this->searchForUnderscoreNamespacedClass();
        }
        else
        {
            $classFound = $this->searchForNonNamespacedClass();
        }

        return $classFound;
    }
684235
public static function getClassName($className) {
    if (is_object($className)) $className = self::getClass($className);
    
    $c = $className;
    if (mb_strpos($className,'\\') !== FALSE) {
      $p = explode('\\',$className);
      $c = array_pop($p);
    }
    return $c;
  }