Replace the class name in the stub.

@param  string $stub
@return $this
773742
protected function replaceClassName(&$stub)
    {
        $className = ucwords(camel_case($this->argument('name')));

        $stub = str_replace('{{class}}', $className, $stub);

        return $this;
    }
752174
protected function replaceModel(string $stub, string $name):string
    {
        $model = $this->getModelNamespace($name);
        $class = $this->getClassFromNamespace($model);

        $stub = str_replace('DummyModelNamespace', $model, $stub);
        $stub = str_replace('DummyModelClass', $class, $stub);
        $stub = str_replace('DummyModelVariable', camel_case($class), $stub);

        return $stub;
    }
1111537
protected function replaceClass($stub, $name)
    {
        $stub = parent::replaceClass($stub, $name . 'Transformer');
        $stub = str_replace('Dummy', ucfirst($this->argument('name')), $stub);
        $stub = str_replace('dummy', lcfirst($this->argument('name')), $stub);

        if ($this->argument('include')) {
            $stub = str_replace('Item', ucfirst($this->argument('include')), $stub);
            $stub = str_replace('item', lcfirst($this->argument('include')), $stub);
        }

        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;
    }
675990
protected function replaceNamespace($stub)
    {
        $stub = str_replace('DummyNamespace', $this->getNamespace(), $stub);
        $stub = str_replace('DummyRootNamespace', trim($this->laravel->getNamespace(), '\\'), $stub);

        return $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;
    }
1310072
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, '\\'));
        $stub = str_replace('DocDummyModel', Str::snake($model, ' '), $stub);
        $stub = str_replace('DummyModel', $model, $stub);

        return str_replace('dummyModel', Str::camel($model), $stub);
    }
301164
protected function replaceModelClass(&$stub, $name)
    {
        $stub = str_replace(
            ['DummyFullModelClass', 'DummyModelClass', 'DummyModelVariable'],
            [$name, class_basename($name), lcfirst(class_basename($name))],
            $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
        );
    }
142023
protected function replaceNamespace(&$stub, $name)
    {
        $stub = str_replace(
            'DummyNamespace', $this->getNamespace($name), $stub
        );

        $stub = str_replace(
            'DummyRootNamespace', $this->laravel->getNamespace().'Laravel\\', $stub
        );

        return $this;
    }
1174224
protected function replace($stub, $name, $model)
    {
        $stub = $this->replaceClass($stub, $name);

        return str_replace(
            ['DummyModelNamespace', 'DummyModel'],
            [$model, class_basename($model)],
            $stub
        );
    }
1073011
protected function replaceNamespace(&$stub, $name)
    {
        $path = $this->option('path');
        $namespace = $this->option('namespace');

        if (!$namespace) {
            $namespace = $this->formGenerator->getClassInfo($name)->namespace;

            if ($path) {
                $namespace = str_replace('/', '\\', trim($path, '/'));
                foreach ($this->getAutoload() as $autoloadNamespace => $autoloadPath) {
                    if (preg_match('|'.$autoloadPath.'|', $path)) {
                        $namespace = str_replace([$autoloadPath, '/'], [$autoloadNamespace, '\\'], trim($path, '/'));
                    }
                }
            }
        }

        $stub = str_replace('{{namespace}}', $namespace, $stub);

        return $this;
    }
554988
protected function replaceClassAndNamespace($name, &$stub)
    {
        $stub = str_replace(
            ['DummyClassWithNamespace', 'DummyClass'],
            [$this->argument('name'), $name],
            $stub
        );

        return $this;
    }
1353976
protected function replaceUserNamespace($stub)
    {
        $model = $this->userProviderModel();

        if (! $model) {
            return $stub;
        }

        return str_replace(
            $this->rootNamespace().'User',
            $model,
            $stub
        );
    }
61492
protected function replaceClass($stub, $name)
    {
        $stub = parent::replaceClass($stub, $name);

        return str_replace('DummyModel', '\\'.trim((string) $this->argument('model'), '\\'), $stub);
    }
211116
protected function replaceModel($stub, $model)
    {
        $model = str_replace('/', '\\', $model);

        $namespaceModel = $this->container->getNamespace() .'Models\\' .$model;

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

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

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

        $stub = str_replace('{{model}}', $model, $stub);

        $stub = str_replace('{{camelModel}}', Str::camel($model), $stub);

        return str_replace('{{pluralModel}}', Str::plural(Str::camel($model)), $stub);
    }
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;
    }