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);
	}
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);
	}
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 ) ; }
Finds a registered namespace by a name.

@param   string  $namespace  A namespace to search for

@return  string

@since   __DEPLOY_VERSION__
@throws  NamespaceNotFoundException When namespace is incorrect or ambiguous
Finds a registered namespace by a name .