Replace the class name for the given stub.

@param string $stub
@param string $name

@return string
12940
protected function replaceClass($stub, $name)
    {
        $class = str_replace($this->getNamespace($name).'\\', '', $name);
        $view = $this->getViewName();

        $stub = str_replace('DummyClass', $class, $stub);

        return str_replace('DummyTemplate', 'admin.dashboard.'.$view, $stub);
    }
440529
protected function replaceSchema(&$stub)
    {
        if ($schema = $this->scaffoldCommandObj->getMeta()['schema'])
        {
            $schema = (new SchemaParser)->parse($schema);
        }

        $schema = (new SyntaxBuilder)->create($schema, $this->scaffoldCommandObj->getMeta());
        $stub = str_replace(['{{schema_up}}', '{{schema_down}}'], $schema, $stub);
        
        return $this;
    }
1337455
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        return $this->option('parent')
                        ? $this->replaceNamespace($stub, $name)->replaceParentClass($stub)->replaceParentFqcn($stub)->replaceClass($stub, $name)
                        : $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);
    }
1170646
protected function replaceVersion(string &$stub, string $version)
    {

        if (strlen($version) > 0)
            $stub = str_replace('v1', $version, $stub);

        return $this;
    }
198979
protected function replaceFields($name, &$stub)
    {
        if (empty($fillable = $this->getFillable())) {
            return str_replace('fields', '//', $stub);
        }

        $fields = 'return [';

        foreach ($fillable as $column) {
            $fields .= PHP_EOL."        '{$column}' => \$faker->word,";
        }

        return str_replace('fields', $fields.PHP_EOL.'    ];', $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;
    }
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;
    }
680487
protected function buildClass($name)
    {
        $subNameArray = explode('.', $name);
        $stub = $this->files->get($this->getStub() . '/' . array_pop($subNameArray) . '.blade.stub');

        return $stub;
    }
437268
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        return $this->replaceClassAndNamespace($name, $stub)->replaceFields($name, $stub);
    }
1316391
protected function replaceModel($stub, $model)
    {
        $model = str_replace('/', '\\', $model);

        $namespaceModel =
            trim($this->laravel->getNamespace(), '\\')
            . $this->getModuleNamespace()
            . config('stubs.namespaces.model') . '\\'
            . $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(config('auth.providers.users.model'));
        $dummyModel = Str::camel($model) === 'user' ? 'model' : Str::camel($model);

        $stub = str_replace('DummyModel', $model, $stub);
        $stub = str_replace('dummyModel', $dummyModel, $stub);
        $stub = str_replace('DummyUser', $dummyUser, $stub);

        return str_replace('dummyPluralModel', Str::plural($dummyModel), $stub);
    }
301164
protected function replaceModelClass(&$stub, $name)
    {
        $stub = str_replace(
            ['DummyFullModelClass', 'DummyModelClass', 'DummyModelVariable'],
            [$name, class_basename($name), lcfirst(class_basename($name))],
            $stub
        );

        return $this;
    }
412648
protected function replaceStubFileData(&$stub)
    {
        $stub = str_replace(
            ['DummyVendor', 'DummyName', 'DummyLowerVendor', 'DummyLowerName'],
            [$this->getVendorInput(), $this->getNameInput(), strtolower($this->getVendorInput()), strtolower($this->getNameInput())],
            $stub
        );

        return $this;
    }
260251
protected function buildClass($name)
    {
        if ($name == $this->qualifyClass('ModelPolicy')) {
            $stub = $this->files->get($this->getStub($name));

            $parent = $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);

            $stub = $this->replaceUserNamespace($parent);

            $model = $this->option('model');

            return $model ? $this->replaceModel($stub, $model) : $stub;
        }

        return parent::buildClass($name);
    }
818768
protected function populateStub($name, $stub, $table)
	{
		$stub = str_replace('{{class}}', studly_case($name), $stub);

		// Here we will replace the table place-holders with the table specified by
		// the developer, which is useful for quickly creating a tables creation
		// or update migration from the console instead of typing it manually.
		if ( ! is_null($table))
		{
			$stub = str_replace('{{table}}', $table, $stub);
		}

		return $stub;
	}
181202
protected function buildClass($name)
    {
        $stub = parent::buildClass($name);

        return $this->replaceType($stub, $name);
    }
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;
    }
221756
protected function replaceCasts(&$stub, $fields){
        $casts = [];
        foreach ($fields as $f){
            if(!empty($f['casts'])) $casts[] = "\"{$f['name']}\"=>\"{$f['casts']}\"";
        }
        if(count($casts)) $casts = "protected \$casts = [".implode(',',$casts)."];";
        else $casts = "";

        $stub = str_replace('DummyCasts', $casts, $stub);

        return $this;
    }