Format the facade stub with the proper namespace and class.

@param  string  $alias
@param  string  $stub
@return string
542710
protected function formatFacadeStub($alias, $stub)
    {
        $replacements = [
            str_replace('/', '\\', dirname(str_replace('\\', '/', $alias))),
            class_basename($alias),
            substr($alias, strlen(static::$facadeNamespace)),
        ];

        return str_replace(
            ['DummyNamespace', 'DummyClass', 'DummyTarget'], $replacements, $stub
        );
    }
1072958
protected function replaceSchemaShow(&$stub)
    {

        if ($schema = $this->scaffoldCommandObj->option('schema')) {
            $schemaArray = (new SchemaParser)->parse($schema);
        }


        // Create view index content fields
        $schema = (new SyntaxBuilder)->create($schemaArray, $this->scaffoldCommandObj->getMeta(), 'view-show-content');
        $stub = str_replace('{{content_fields}}', $schema, $stub);


        return $this;
    }
549892
protected function makeTransformer(string $name, string $stub):string
    {
        $stub = $this->replaceNamespace($stub);
        $stub = $this->replaceClass($stub, $name);
        $stub = $this->replaceModel($stub, $name);

        return $stub;
    }
181409
protected function replaceModel($stub, $model)
    {
        $model = str_replace('/', '\\', $model);

        $namespaceModel = $this->laravel->getNamespace().$model;

        if (Str::startsWith($model, '\\')) {
            $stub = str_replace('NamespacedDummyModel', trim($model, '\\'), $stub);
        } else {
            $stub = str_replace('NamespacedDummyModel', $namespaceModel, $stub);
        }

        $stub = str_replace(
            "use {$namespaceModel};\nuse {$namespaceModel};", "use {$namespaceModel};", $stub
        );

        $model = class_basename(trim($model, '\\'));

        $dummyUser = class_basename($this->userProviderModel());

        $dummyModel = Str::camel($model) === 'user' ? 'model' : $model;

        $stub = str_replace('DocDummyModel', Str::snake($dummyModel, ' '), $stub);

        $stub = str_replace('DummyModel', $model, $stub);

        $stub = str_replace('dummyModel', Str::camel($dummyModel), $stub);

        $stub = str_replace('DummyUser', $dummyUser, $stub);

        return str_replace('DocDummyPluralModel', Str::snake(Str::pluralStudly($dummyModel), ' '), $stub);
    }
804386
protected function replaceSchema(&$stub)
    {
        $tables = $this->getSortedTableNames();
        $stub = str_replace(
            ['{{columnOne}}', '{{columnTwo}}', '{{tableOne}}', '{{tableTwo}}'],
            array_merge(array_map('str_singular', $tables), $tables),
            $stub
        );
        return $this;
    }
1329398
protected function replaceUserNamespace($stub): string
    {
        if (! $userModel = config('auth.providers.'.config('auth.guards.'.config('auth.defaults.guard').'.provider').'.model')) {
            return $stub;
        }

        return str_replace(
            $this->rootNamespace().'User',
            $userModel,
            $stub
        );
    }
987890
protected function buildClass($name)
    {
        $stub = parent::buildClass($name);

        $modelName = $this->getModelClass($name);

        $this->replaceModelNamespace($stub, $modelName)
             ->replaceModelClass($stub, $modelName)
             ->replaceBaseRepositoryNamespace($stub, $this->base)
             ->replaceBaseRepositoryClass($stub, $this->base);

        return $stub;
    }
737278
protected function replaceNamespace(&$stub)
    {
        $rootNamespace = App::getNamespace();

        $module = Module::get($this->getIdentifierInput());

        $baseNamespace = $module['namespace'];

        $namespace = $baseNamespace . "Http\Controllers";

        $stub = str_replace(
            ['DummyClass', 'DummyRootNamespace', 'DummyNamespace'],
            [$this->getNameInput(), $rootNamespace, $namespace],
            $stub
        );

        return $this;
    }
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;
    }
539340
public function replaceClassName($stub, $tableName)
    {
        return str_replace('{{class}}', $this->options['singular'] ? str_singular(studly_case($tableName)): studly_case($tableName), $stub);
    }
475406
protected function beforeApplyOptions($stub)
	{
		$refModel = new ReflectionClass($this->model);
		$refIntermeidateModel = new ReflectionClass($this->defaultOptions['intermediate_model']);
		
		$model = $refIntermeidateModel->getShortName();
		
		if ($refModel->getNamespaceName() !== $refIntermeidateModel->getNamespaceName()) {
			$model = '\\'.$refIntermeidateModel->getName();
		}

		return str_replace('DummyIntermediateModel', $model, $stub);
	}
800971
protected function replaceTable(&$stub, $name)
    {
        $name = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', str_replace($this->getNamespace($name).'\\', '', $name))), '_');

        $table = Str::snake(Str::plural($name));

        $stub = str_replace('DummyTable', $table, $stub);

        return $this;
    }
681019
protected function compileStub($stub, array $data)
    {
        $stub = $this->files->get(__DIR__ . '/../stub/' . $stub);

        foreach ($data as $key => $value) {
            $stub = str_replace('{{' . $key . '}}', $value, $stub);
        }

        return $stub;
    }
356329
protected function buildFillable(&$stub)
    {
        $schemaArray = [];

        $schema = $this->scaffoldCommandObj->getMeta()['schema'];

        if ($schema)
        {
            $items = (new SchemaParser)->parse($schema);
            foreach($items as $item)
            {
                $schemaArray[] = "'{$item['name']}'";
            }

            $schemaArray = join(", ", $schemaArray);
        }

        $stub = str_replace('{{fillable}}', $schemaArray, $stub);

        return $this;
    }
1261955
public function alias($alias = null)
    {
        deprecationWarning(
            get_called_class() . '::alias() is deprecated. ' .
            'Use setAlias()/getAlias() instead.'
        );
        if ($alias !== null) {
            $this->setAlias($alias);
        }

        return $this->getAlias();
    }
106116
protected function replaceNamespace(array $segments, $stub)
	{
		if (count($segments) > 1)
		{
			$namespace = implode('\\', array_slice($segments, 0, -1));

			return str_replace('{{namespace}}', ' namespace '.$namespace.';', $stub);
		}
		else
		{
			return str_replace('{{namespace}}', '', $stub);
		}
	}
1254399
protected function replaceSchemaIndex(&$stub)
    {

        if ($schema = $this->scaffoldCommandObj->option('schema')) {
            $schemaArray = (new SchemaParser)->parse($schema);
        }


        // Create view index header fields
        $schema = (new SyntaxBuilder)->create($schemaArray, $this->scaffoldCommandObj->getMeta(), 'view-index-header');
        $stub = str_replace('{{header_fields}}', $schema, $stub);


        // Create view index content fields
        $schema = (new SyntaxBuilder)->create($schemaArray, $this->scaffoldCommandObj->getMeta(), 'view-index-content');
        $stub = str_replace('{{content_fields}}', $schema, $stub);


        return $this;
    }