Returns the default class of $namespace.

@param string $namespace Namespace of the controller
@return array Default method and controller
4950
public static function getNamespaceDefaultClass($namespace, $defaultNamespace) {
        if (strpos($namespace, $defaultNamespace) === 0) {
            $namespace = substr($namespace, strlen($defaultNamespace));
        }

        $defaults = self::$_config['defaults'];
        $controller = $defaults[str_replace('\\', '/', $namespace)];

        if (!$controller) {
            $controller = $defaults['*'] ? $defaults['*'] : 'Index';
        }

        return $controller;
    }
978456
protected function getClient($namespace) {
		$path = sprintf('%s/configs/%s/%s/%s?releaseKey=%s',
			$this->conf['path'],
			$this->conf['appid'],
			$this->conf['cluster'],
			$this->conf['namespace'],
			$this->last_key);
		if ($this->conf['with_ip']) {
			$cidr = Container::getInstance()->get(CIDRmatch::class);
			foreach (swoole_get_local_ip() as $v) {
				if ($cidr->match($v, $this->conf['with_ip'])) {
					$path .= '&ip=' . $v;
					break;
				}
			}
		}
		$cli = new Client($this->conf['host'], $this->conf['port']);
		$cli->set([
			'timeout' => 1
		]);
		$cli->setDefer();
		$cli->get($path);
		return $cli;
	}
949632
public static function getNamespace($namespaceClass)
    {
        if (is_object($namespaceClass) === true) {
            $namespaceClass = get_class($namespaceClass);
        }
    
        $lastSlashPosition = mb_strrpos($namespaceClass, '\\');
    
        if ($lastSlashPosition !== false) {
            return mb_substr($namespaceClass, 0, $lastSlashPosition);
        }
    
        return "";
    }
560641
public function all($namespace = null)
    {
        $this->init();

        if (null === $namespace) {
            if (!$this->commandLoader) {
                return $this->commands;
            }

            $commands = $this->commands;
            foreach ($this->commandLoader->getNames() as $name) {
                if (!isset($commands[$name]) && $this->has($name)) {
                    $commands[$name] = $this->get($name);
                }
            }

            return $commands;
        }

        $commands = [];
        foreach ($this->commands as $name => $command) {
            if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
                $commands[$name] = $command;
            }
        }

        if ($this->commandLoader) {
            foreach ($this->commandLoader->getNames() as $name) {
                if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1) && $this->has($name)) {
                    $commands[$name] = $this->get($name);
                }
            }
        }

        return $commands;
    }
986491
public function getPrefixForDocumentNamespace( $namespace )
	{
		if ( is_null( $this->cacheDocumentNamespaces ) )
		{
			$this->cacheDocumentNamespaces = array_flip( $this->instance_xml->getDocNamespaces() );
			// If the default namespace is one of the standards ones then the prefix may be missing
			$standardNamespaces = array_flip( XBRL_Constants::$standardPrefixes );
			$docNamespace = array_search( '', $this->cacheDocumentNamespaces );
			if ( $docNamespace )
			{
				if ( isset( $standardNamespaces[ $docNamespace ] ) )
				{
					$this->cacheDocumentNamespaces[ $docNamespace ] = $standardNamespaces[ $docNamespace ];
				}
				else
				{
					// Get the namespace for the respective namespace
					$taxonomy = $this->getInstanceTaxonomy()->getTaxonomyForNamespace( $docNamespace );
					if ( $taxonomy )
					{
						$this->cacheDocumentNamespaces[ $docNamespace ] = $taxonomy->getPrefix();
					}
				}
			}
		}

		return isset( $this->cacheDocumentNamespaces[ $namespace ] )
			? $this->cacheDocumentNamespaces[ $namespace ]
			: false;
	}
1203212
public function getAllCommands(string $namespace = ''): array
	{
		$this->initCommands();

		if ($namespace === '')
		{
			$commands = $this->commands;

			if (!$this->commandLoader)
			{
				return $commands;
			}

			foreach ($this->commandLoader->getNames() as $name)
			{
				if (!isset($commands[$name]))
				{
					$commands[$name] = $this->getCommand($name);
				}
			}

			return $commands;
		}

		$commands = [];

		foreach ($this->commands as $name => $command)
		{
			if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1))
			{
				$commands[$name] = $command;
			}
		}

		if ($this->commandLoader)
		{
			foreach ($this->commandLoader->getNames() as $name)
			{
				if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1))
				{
					$commands[$name] = $this->getCommand($name);
				}
			}
		}

		return $commands;
	}
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;
	}
967646
protected function getNamespace($namespace = null)
    {
        if (!is_null($namespace)) {
            $parts = explode('\\', $namespace);

            array_pop($parts);

            return join('\\', $parts);
        }

        return $this->getAppNamespace() . $this->namespace;
    }
792361
protected function getClassNamesInNamespace($namespace)
    {
        $affectedViewHelperClassNames = [];

        $allViewHelperClassNames = $this->reflectionService->getAllSubClassNamesForClass(AbstractViewHelper::class);
        foreach ($allViewHelperClassNames as $viewHelperClassName) {
            if ($this->reflectionService->isClassAbstract($viewHelperClassName)) {
                continue;
            }
            if (strncmp($namespace, $viewHelperClassName, strlen($namespace)) === 0) {
                $affectedViewHelperClassNames[] = $viewHelperClassName;
            }
        }
        sort($affectedViewHelperClassNames);
        return $affectedViewHelperClassNames;
    }
617391
public function getZendStorage(string $namespace = 'default')
    {
        static $storages = [];
        
        if (!isset($storages[$namespace])) {
            $rrm = new RedisResourceManager();
            $rrm->setResource('default', $this->getRedis());
            $rrm->setLibOption('default', Redis::OPT_SERIALIZER, $this->redis->getOption(Redis::OPT_SERIALIZER));
            $options = new RedisOptions();
            $options->setResourceManager($rrm);
            $storages[$namespace] = new RedisAdapter($options);
        }
        return $storages[$namespace];
    }
1082942
protected function getDefaultNamespace($rootNamespace)
    {
        $namespace = Config::get('service-classes.cached_services.namespace');
        $serviceNamespace = Config::get('service-classes.namespace');

        if (! $serviceNamespace) {
            throw InvalidNamespaceException::missingServiceNamespace();
        }

        return $this->defaultNamespace = $namespace ? $rootNamespace.'\\'.Config::get('service-classes.namespace').'\\'.$namespace
                      : $rootNamespace.'\\'.Config::get('service-classes.cached_services.namespace');
    }
43564
protected function getNamespacesFromClass($namespace)
    {
        $classStack = [$namespace];
        $classStack = array_merge($classStack, class_parents($namespace));
        $classStack = array_merge($classStack, class_implements($namespace));

        return $classStack;
    }
1004175
public function getNamespace()
    {
        if (is_null($this->_namespace)) {
            $namespace = $this->getConfiguration()
                ->get('router.namespace', 'Controllers');
            if (isset($this->_params['namespace'])) {
                $namespace = $this->_params['namespace'];
            }
            $this->_namespace = trim($namespace, '\\');
        }
        return $this->_namespace;
    }
832073
static public function formatNamespace($namespace)
	{
	    if (is_array($namespace)) {
	        foreach ($namespace as $k => $v) {
	            $namespace[$k] =  static::formatNamespace($v);
	        }
	    } else {
	        $namespace = trim(str_replace('/', '\\', $namespace), '\\') . '\\';
	    }
	    
	    return $namespace;
	}
1022267
protected function _classesInNamespaces($names, array $namespaces, array &$logs = array())
    {
        if (!is_array($names)) {
            $names = array($names);
        }
        foreach ($names as $_name) {
            foreach ($namespaces as $_namespace) {
                if (CodeHelper::namespaceExists($_namespace)) {
                    $tmp_namespace = rtrim(TextHelper::toCamelCase($_namespace), '\\').'\\';
                    if (substr_count(TextHelper::toCamelCase($_name), $tmp_namespace)>0) {
                        return $_name;
                    }
                } else {
                    $logs[] = $this->_getErrorMessage('Namespace "%s" not found!', $_namespace);
                }
            }
        }
        return false;
    }
644083
public function unsetOverrider($namespace = null)
    {
        if (is_null($namespace)) {
            $this->overrides = [];
        } else {
            unset($this->overrides[$namespace]);
        }

        $this->makeLog('Override unset for: ' . $namespace);

        return $this;
    }
548374
private static function _getController($uri, $namespace) {
        $dir = realpath(APP_PATH . '/../' . $namespace) . DIRECTORY_SEPARATOR;

        if (!is_dir($dir . $uri)) {
            $uriParts = explode('/', $uri, 2);
            if (is_dir($dir . $uriParts[0])) {
                return self::_getController($uriParts[1], $namespace . $uriParts[0] . '\\');
            } elseif (is_file($dir . $uriParts[0] . '.php')) {
                $uri = $uriParts[0];
            }
        } else {
            $namespace = $namespace . '\\' . str_replace('/', '\\', $uri);
            $uri = '';
        }

        if (substr($namespace, -1) == '\\') {
            $namespace = substr($namespace, 0, strlen($namespace) - 1);
        }
        if (!$uri) {
            $uri = self::getNamespaceDefaultClass($namespace, 'App\\'); // Sets the default class
        }

        return self::fixNamespace($namespace . '\\' . $uri);
    }