Split class name

@param string $className Class name with namespace
@return string Namespace
170130
public static function splitClassName ( $className )
    {
        $chunk = explode('\\', $className);
        $className = array_pop($chunk);
        $namespace = implode('\\', $chunk);
        $result = array($namespace, $className);
        return $result;
    }
1319500
public static function getShortClassname($classname)
    {
        if (is_array($classname)) {
            return  array_map(['BackBee\ClassContent\AbstractContent', 'getShortClassname'], $classname);
        }

        if (in_array($classname, ['scalar', 'array'])) {
            return $classname;
        }

        $isExcluded = self::isExcludedClassname($classname);

        try {
            if (!is_subclass_of($classname, 'BackBee\ClassContent\AbstractClassContent')) {
                throw new ClassNotFoundException();
            }
        } catch (ClassNotFoundException $ex) {
            return self::onUnknownClassname(
                sprintf('Given classname %s is not a subclass of AbstractClassContent.', $classname),
                $ex
            );
        }

        return ($isExcluded ? '!' : '').str_replace(self::CLASSCONTENT_BASE_NAMESPACE, '', $classname);
    }
1313124
public static function getOnlyNameSpace($className)
    {
        // Try to find namespace separator
        if (($p = strrpos($className, self::NS_SEPARATOR)) !== false) {
            $className = substr($className, 0, $p);
        }

        return $className;
    }
192469
public static function getNamespace($className)
    {
        if (is_object($className)) {
            $className = get_class($className);
        }
        if (strpos($className, '\\') === false) {
            return '';
        }
        return preg_replace('/\\\\[^\\\\]+$/', '', $className);
    }
323610
protected function replaceStubString($className, $namespace)
    {
        return array_merge([
            'VENDOR_NAME_LOWER'  => strtolower($this->vendor),
            'VENDOR_NAME'        => studly_case($this->vendor),
            'PACKAGE_NAME_LOWER' => strtolower($this->package),
            'PACKAGE_NAME'       => studly_case($this->package),
            'DummyClass'         => studly_case($className),
            'DummyTarget'        => strtolower($className),
            'DummyNamespace'     => $this->namespace . $namespace,
            'DummyRootNamespace' => $this->laravel->getNamespace(),
        ], $this->config->get('tie.stubs.replace'));
    }
449461
public function fullyQualifiedClassName($className)
    {
        if ($className !== null && strpos($className, '\\') === false && strlen($this->namespace) > 0) {
            return $this->namespace.'\\'.$className;
        }

        return $className;
    }
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);
	}
644766
public function getFullyQualifiedClassName(string $className, string $defaultNamespace) : string
    {
        $rootNamespace = $this->getRootNamespace();

        // If the class name is already fully-qualified
        if (mb_strpos($className, $rootNamespace) === 0) {
            return $className;
        }

        return trim($defaultNamespace, '\\') . '\\' . $className;
    }
1342922
private static function getFullNamespace($filename)
    {
        $lines = file($filename);
        $namespaceLine = preg_grep('/^namespace /', $lines);
        $namespaceLine = array_shift($namespaceLine);

        $match = array();
        preg_match('#(namespace)(\\s+)([A-Za-z0-9\\\\]+?)(\\s*);#sm', $namespaceLine, $match);

        $fullNamespace = $match['3'];

        return $fullNamespace;
    }
1074512
public static function deNamespace($className)
        {
            $className = trim($className, '\\');

            if ($lastSeparator = strrpos($className, '\\')) {
                $className = substr($className, $lastSeparator + 1);
            }

            return $className;
        }
333195
public function load($className)
    {
        $class = ltrim($className, '\\');

        if (strpos($class, $this->namespace) !== 0) {
            return false;
        }

        $nsparts   = explode('\\', $class);
        $class     = array_pop($nsparts);
        $nsparts[] = '';
        $path      = $this->path . implode(DIRECTORY_SEPARATOR, $nsparts);
        $path     .= str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';

        if (!is_readable($path)) {
            return false;
        }

        require $path;

        return class_exists($className,false);
    }
1230021
public function loadClass($className)
    {
        if (null === $this->_namespace || $this->_namespace.$this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace.$this->_namespaceSeparator))) {
            $fileName = '';
            $namespace = '';
            if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
                $namespace = substr($className, 0, $lastNsPos);
                $className = substr($className, $lastNsPos + 1);
                $fileName = str_replace($this->_namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
            }
            $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->_fileExtension;
            $filePath = ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;

            if (file_exists($filePath)) {
                require $filePath;
            }
        }
    }
928307
protected final function fileName(string $className): string
    {
        $fileName = "";
        if (array_key_exists($className, $this->className)) {
            $fileName = $this->className[$className];
            $this->removeClass($className);
        }
        return $fileName;
    }
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;
    }
1019116
public static function getNamespace($className)
        {
            $className = trim($className, '\\');

            if ($lastSeparator = strrpos($className, '\\')) {
                return substr($className, 0, $lastSeparator + 1);
            }

            return '';
        }
682395
protected function getClassName($className) {
        if (strpos($className, ':') !== false) {
           list($namespaceAlias, $simpleClassName) = explode(':', $className);
           $className = $this->doctrine->getManager()->getConfiguration()
               ->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
        }
        return $className;
    }
577160
public function getProxyNamespace($className)
    {
        $proxyClassName = $this->getProxyClassName($className);
        $parts = explode('\\', strrev($proxyClassName), 2);
    
        return strrev($parts[1]);
    }