Format the facade stub with the proper namespace and class.

@param  string $alias

@return string
770306
protected function formatFacadeCode(string $alias): string
    {
        static $len;
        if ($len === null) {
            $len = \strlen(self::FACADE_NAMESPACE);
        }

        $path = \str_replace('\\', '/', $alias);

        $namespace = \str_replace('/', '\\', \dirname($path));
        $class = \basename($path);
        $target = '\\' . \substr($alias, $len);

        $code = <<<STUB
<?php
namespace $namespace;

use Hail\Facade\FacadeDynamic;

/**
 * @see $target
 */
class $class extends FacadeDynamic
{
    protected static \$name = '$target';
}
STUB;

        return $code;
    }
225387
public function resolveNS($ns)
    {
        if ($ns[0] !== '@') {
            return $ns;
        }

        $parts = explode('\\', $ns, 2);

        $alias = $parts[0];
        if (!isset($this->_aliases[$alias])) {
            throw new InvalidArgumentException(['`:alias` is not exists for `:namespace`', 'alias' => $alias, 'namespace' => $ns]);
        }

        return $this->_aliases[$alias] . (isset($parts[1]) ? '\\' . $parts[1] : '');
    }
749691
public function alias(string $alias = null)
    {
        $clone = clone $this;
        $clone->value = sprintf('%s AS %s', $clone->value, $this->quoter->quoteName($alias));

        return $clone;
    }
283927
public function getAlias($alias) {
		if (!is_string($alias)) {
			return $alias;
		}

		if (array_key_exists($alias, $this->aliases)) {
			return $this->aliases[$alias];
		}

		return $alias;
	}
1244148
public function alias($alias = null)
    {
        if ($alias !== null) {
            $this->setAlias($alias);
        }

        return $this->getAlias();
    }
83868
public function resolve($alias)
	{
		// Check wether the alias matches the pattern
		if ( ! preg_match($this->regex, $alias, $matches))
		{
			return false;
		}

		// Get the translation
		$translation = $this->translation;

		if (strpos($translation, '$') === false)
		{
			$class = $translation;
		}
		else
		{
			// Make sure namespace seperators are escaped
			$translation = str_replace('\\', '\\\\', $translation);

			// Resolve the replacement
			$class = preg_replace($this->regex, $translation, $alias);
		}

		// Check wether the class exists
		if ($class and $this->objectExists($class, true))
		{
			return $class;
		}

		return false;
	}
1244140
public function load(string $alias): ?bool
    {
        if (\strpos($alias, self::FACADE_NAMESPACE) === 0) {
            return $this->loadFacade($alias);
        }

        if (isset($this->aliases[$alias])) {
            return \class_alias($this->aliases[$alias], $alias);
        }

        return null;
    }
252779
protected function normalizeAlias($alias)
    {
        $normalized = preg_replace('/[^a-zA-Z0-9]/', ' ', $alias);
        $normalized = 'new' . str_replace(' ', '', ucwords($normalized));
        return $normalized;
    }
784243
protected function prepareAlias($alias, $concrete)
    {
        if ( ! $alias && $alias !== false && ! $concrete instanceof \Closure) {
            $alias = str_replace('{class}', $concrete, $this->aliasPattern);
        }

        return $alias;
    }
353312
public function setAlias($alias)
    {
        $aliasManipulator = new AliasManipulator($this->originalDir, $this->alias);
        $aliasManipulator->setAlias($alias);

        return $aliasManipulator;
    }
115059
public function namespace(string $namespace, string $alias = null) : Manager
    {
        $this->namespaces[] = [trim($namespace, '\\'), trim($alias, '\\')];

        return $this;
    }
194321
function isExtendedService($alias)
    {
        $cAlias = $this->_normalizeName($alias);
        return isset($this->aliases[$cAlias]);
    }
758761
public function toLdapFilter($alias = null)
    {
        if ($this->skipFilterForAlias($alias)) {
            return '';
        }
        if ($this->getValueForQuery($alias) instanceof BaseOperator) {
            return $this->getValueForQuery($alias)->toLdapFilter($alias);
        }

        return self::SEPARATOR_START
            .$this->getAttributeToQuery($alias)
            .$this->operatorSymbol
            .LdapUtilities::escapeValue($this->getValueForQuery($alias), null, LDAP_ESCAPE_FILTER)
            .self::SEPARATOR_END;
    }
780617
public function toNamespacedString($namespace, array $aliased_classes, $this_class, $use_phpdoc_format)
    {
        if ($this->as === 'object') {
            return 'class-string';
        }

        if ($namespace && stripos($this->as, $namespace . '\\') === 0) {
            return 'class-string<' . preg_replace(
                '/^' . preg_quote($namespace . '\\') . '/i',
                '',
                $this->as
            ) . '>';
        }

        if (!$namespace && stripos($this->as, '\\') === false) {
            return 'class-string<' . $this->as . '>';
        }

        if (isset($aliased_classes[strtolower($this->as)])) {
            return 'class-string<' . $aliased_classes[strtolower($this->as)] . '>';
        }

        return 'class-string<\\' . $this->as . '>';
    }
1102281
public function setAlias($alias) {
    if (is_string($alias)) {
      $alias = new TokenNode(T_STRING, $alias);
    }

    if ($alias instanceof TokenNode) {
      if ($this->hasAlias()) {
        $this->alias->replaceWith($alias);
      }
      else {
        $this->alias = $alias;
        $this->addChild(WhitespaceNode::create(' '));
        $this->addChild(Token::_as());
        $this->addChild(WhitespaceNode::create(' '));
        $this->addChild($alias, 'alias');
      }
    }
    elseif ($alias === NULL && $this->hasAlias()) {
      $this->alias->previousUntil(Filter::isInstanceOf('\Pharborist\Namespaces\NameNode'))->remove();
      $this->alias->remove();
      $this->alias = NULL;
    }
    else {
      throw new \InvalidArgumentException();
    }

    return $this;
  }
238008
public function alias(string $alias): AliasInterface
    {
        if (!in_array($alias, $this->alias)) {
            $this->alias[] = $alias;
        }
        $this->aliasHelper($alias);

        return $this;
    }
820929
public static function getAlias($alias)
    {
        $alias = strtolower($alias);

        return array_key_exists($alias, self::$aliases) ? self::$aliases[$alias] : false;
    }