Returns the class with namespace prefix when available

@param	string
@return	bool|string
336984
protected static function find_core_class($class)
	{
		foreach (static::$core_namespaces as $ns)
		{
			if (array_key_exists(strtolower($ns_class = $ns.'\\'.$class), static::$classes))
			{
				return $ns_class;
			}
		}

		return false;
	}
825838
public function loadClass($class)
    {
        $prefix = $class;

        while (($pos = strrpos($prefix, '\\')) !== false) {
            $prefix = substr($class, 0, $pos + 1);
            $relativeClass = substr($class, $pos + 1);

            $mappedFile = $this->_loadMappedFile($prefix, $relativeClass);
            if ($mappedFile) {
                return $mappedFile;
            }

            $prefix = rtrim($prefix, '\\');
        }

        return false;
    }
503685
public function getTaxonomyForNamespace( $namespace )
	{
		if ( ! isset( $this->context->importedSchemas[ $namespace ] ) )
		{
			if ( XBRL::endsWith( $namespace, '/' ) )
			{
				$namespace = substr( $namespace, 0, strlen( $namespace ) - 1 );
			}
			else if ( ! XBRL::endsWith( $namespace, '/' ) )

			{
				$namespace .= '/';
			}
			if ( ! isset( $this->context->importedSchemas[ $namespace ] ) )
			{
				return false;
			}
		}

		return $this->context->importedSchemas[ $namespace ];
	}
1325847
public function getPrefixForNamespace( $namespace )
	{
		if (
			  ! isset( $this->cacheNamespaces ) ||
			  count( $this->cacheNamespaces ) != count( $this->instance_namespaces )
		   )
		{
			$this->cacheNamespaces = array_flip( $this->instance_namespaces );
			// If the default namespace is one of the standards ones then the prefix may be missing
			$standardNamespaces = array_flip( XBRL_Constants::$standardPrefixes );
			if ( isset( $this->instance_namespaces[''] ) )
			{
				if ( isset( $standardNamespaces[ $this->instance_namespaces[''] ] ) )
				{
					$this->cacheNamespaces[ $this->instance_namespaces[''] ] = $standardNamespaces[ $this->instance_namespaces[''] ];
				}
			}
		}

		return isset( $this->cacheNamespaces[ $namespace ] )
			? $this->cacheNamespaces[ $namespace ]
			: false;
	}
497406
public function getNamespaceByName( $name ) {
		$result = $this->getNamespaceResult()['query'];
		foreach ( $result['namespaces'] as $nsInfo ) {
			if ( ( !empty( $nsInfo['canonical'] ) && $nsInfo['canonical'] === $name ) ||
				$nsInfo['*'] === $name ) {
				return $this->createNamespaceFromQuery( $nsInfo, $result['namespacealiases'] );
			}
		}
		foreach ( $result['namespacealiases'] as $alias ) {
			if ( $alias['*'] === $name && !empty( $result['namespaces'][$alias['id']] ) ) {
				return $this->createNamespaceFromQuery(
					$result['namespaces'][$alias['id']],
					$result['namespacealiases']
				);
			}
		}
		return null;
	}
37061
public function getClassNamespace(bool $prefix = false): string
	{
		if($this->classNamespace === null)
		{
			$this->classNamespace = substr(static::class, 0, strrpos(static::class, '\\'));
		}

		return $prefix ? '\\' . $this->classNamespace : $this->classNamespace;
	}
1301995
protected function _getClassName($class)
    {
        $class = Str::low($class);
        list ($plugin, $className) = pluginSplit($class);
        $return = self::HELPER_SUFFIX . '\\' . Inflector::camelize($className) . self::HELPER_SUFFIX;
        if ($plugin !== null) {
            return Inflector::camelize($plugin) . '\\' . $return;
        }

        return Configure::read('App.namespace') . '\\' . $return;
    }
1285617
public function getPrefix(string $prefix, string $className): string
    {
        // the  prefix of annotation is exist
        if (! empty($prefix)) {
            return $prefix;
        }

        // the prefix of annotation is empty
        $reg = '/^.*\\\(\w+)' . $this->suffix . '$/';
        $prefix = '';

        if ($result = preg_match($reg, $className, $match)) {
            $prefix = lcfirst($match[1]);
        }

        return $prefix;
    }
1048736
protected function _getNamespace($className, $pluginPath = null, $prefixPath = null)
    {
        $namespace = preg_replace('/(.*)Controller\//', '', $className);
        $namespace = preg_replace('/\//', '\\', $namespace);
        $namespace = preg_replace('/\.php/', '', $namespace);
        $prefixPath = preg_replace('/\//', '\\', Inflector::camelize($prefixPath));
        if (!$pluginPath) {
            $rootNamespace = Configure::read('App.namespace');
        } else {
            $rootNamespace = preg_replace('/\//', '\\', $pluginPath);
        }
        $namespace = [
            $rootNamespace,
            'Controller',
            $prefixPath,
            $namespace
        ];

        return implode('\\', Hash::filter($namespace));
    }
1107443
protected function getClassNamePrefix()
    {
        $prefix = $this->input->getOption('prefix');

        if (empty($prefix)) {
            $prefix = $this->classNamePrefix;
        }

        return $prefix;
    }
1337211
public static function get($name)
    {
        $namespaces = config('crude.namespace');

        if (! is_array($namespaces)) {
            $fullName = $namespaces . $name;

            return class_exists($fullName)
                ? new $fullName()
                : null;
        }

        foreach ($namespaces as $namespace) {
            $fullName = $namespace . $name;
            if (class_exists($fullName))
                return new $fullName();
        }

        return null;
    }
1305002
public function load($className)
    {
        // get namespace of current instance
        $currentNamespace = $this->namespace.$this->namespaceSeparator;

        // get namespace from passed className
        $namespace = substr($className, 0, strlen($currentNamespace));

        // check if requested class must be loaded by this instance of loader
        // this is a good example use case for namespacing which makes sense
        if (
            $this->namespace === null ||
            $currentNamespace === $namespace
        ) {
            $filename = '';
            $lastNamespaceSeparatorPosition = strripos($className, $this->namespaceSeparator);

            if ($lastNamespaceSeparatorPosition !== false) {
                $namespace = substr($className, 0, $lastNamespaceSeparatorPosition);
                $className = substr($className, $lastNamespaceSeparatorPosition + 1);
                $filename  = str_replace(
                    $this->namespaceSeparator,
                    $this->separator,
                    $namespace
                ).$this->separator;
            }

            $filename .= str_replace('_', $this->separator, $className).'.php';
            $path      = $this->getPath();

            if ($path !== null) {
                foreach ($path as $singlePath) {
                    $filename = $singlePath.$this->separator.$filename;
                    if (file_exists($filename)) {
                        include_once $filename;
                        return true;
                    }
                }
            }
        }

        return false;
    }
1145641
public static function getNamespace($tokens)
    {
        $count = count($tokens);
        $i = 0;
        $namespace = '';
        $namespace_ok = false;
        while ($i < $count) {
            $token = $tokens[$i];
            if (is_array($token) && $token[0] === T_NAMESPACE) {
                // Found namespace declaration
                while (++$i < $count) {
                    if ($tokens[$i] === ';') {
                        $namespace_ok = true;
                        $namespace = trim($namespace);
                        break;
                    }
                    $namespace .= is_array($tokens[$i]) ? $tokens[$i][1] : $tokens[$i];
                }
                break;
            }
            $i++;
        }
        if (!$namespace_ok) {
            return null;
        } else {
            return $namespace;
        }
    }
1154700
public function findNamespace(string $namespace): string
	{
		$allNamespaces = $this->getNamespaces();

		$expr = preg_replace_callback(
			'{([^:]+|)}',
			function ($matches)
			{
				return preg_quote($matches[1]) . '[^:]*';
			},
			$namespace
		);

		$namespaces = preg_grep('{^' . $expr . '}', $allNamespaces);

		if (empty($namespaces))
		{
			throw new NamespaceNotFoundException(sprintf('There are no commands defined in the "%s" namespace.', $namespace));
		}

		$exact = \in_array($namespace, $namespaces, true);

		if (\count($namespaces) > 1 && !$exact)
		{
			throw new NamespaceNotFoundException(sprintf('The namespace "%s" is ambiguous.', $namespace));
		}

		return $exact ? $namespace : reset($namespaces);
	}
369549
public function findClassName($className)
    {
        if (!empty($this->lookupCache->classes[$className])) {
            return $this->lookupCache->classes[$className];
        }

        if (class_exists($className)) return $className;
        $startsWithSlash = ($className[0] == '\\');

        foreach ($this->searchOrder as $namespace)
        {
            $testClass = '\\' . $namespace;
            if (!$startsWithSlash) {
                $testClass .= '\\';
            }

            $testClass .= $className;

            if (class_exists($testClass)) {
                $this->lookupCache->classes[$className] = $testClass;
                return $testClass;
            }
        }

        return null;
    }
360605
public function loadClass($className)
    {

        // concatenate namespace and separator
        $namespaceAndSeparator = $this->namespace . $this->namespaceSeparator;

        // if a namespace is available OR the classname contains a namespace
        if ($namespaceAndSeparator === substr($className, 0, strlen($namespaceAndSeparator)) || $this->namespace === null) {
            // initialize filename, classname and namespace
            $fileName = '';
            $namespace = '';
            if (($lastNsPos = strripos($className, $this->namespaceSeparator)) !== false) {
                $namespace = substr($className, 0, $lastNsPos);
                $className = substr($className, $lastNsPos + 1);
                $fileName = str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
            }

            // prepare filename
            $fileName .= $className . $this->fileExtension;

            // try to load the requested class
            $toRequire = $this->includePath . DIRECTORY_SEPARATOR . $fileName;
            $psr4FileName = $this->includePath . DIRECTORY_SEPARATOR . ltrim(strstr(ltrim(strstr($fileName, DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);

            // query whether or tno the file exsists
            if (file_exists($toRequire)) {
                // require the file and return TRUE
                require $toRequire;
                return true;

            } elseif (file_exists($psr4FileName) && !is_dir($psr4FileName)) {
                // require the file and return TRUE
                require $psr4FileName;
                return true;
            }
        }
    }
546765
public static function getNamespace($classPath)
    {
        $src = file_get_contents($classPath);

        if (preg_match('/namespace\s+(.+?);/', $src, $m)) {
            return $m[1];
        }

        return null;
    }