Replace the class name for the given stub.

@param  string  $stub
@param  string  $name
@return string
978967
protected function replaceClass($stub, $name)
    {
        $stub = parent::replaceClass($stub, $name);

        $type = basename(str_replace('\\', '/', strtolower($name)));
        if ($this->option('type')) {
            $type = $this->option('type');
        }

        return str_replace('dummy_type', $type, $stub);
    }
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);
    }
292750
protected function replaceSingularServiceVar($name){
        //dd($name);
        $class = str_replace($this->getNamespace($name).'\\', '', $name);
        $class = strtolower(snake_case(str_replace('Service', '', $class)));
        //dd($class);
        return $class;
    }
198896
protected function replaceBaseRepositoryClass(&$stub, $name)
    {
        $baseClass = str_replace($this->getNamespace($name) . '\\', '', $name);
        $stub      = str_replace('BaseRepositoryClass', $baseClass, $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);
    }
1224219
protected function getReplacement($stub)
    {
        $replacements = $this->module->config('stubs.replacements');

        if (!isset($replacements[$stub])) {
            return [];
        }

        $keys = $replacements[$stub];

        $replaces = [];

        foreach ($keys as $key) {
            if (method_exists($this, $method = 'get' . ucfirst(Str::studly(strtolower($key))) . 'Replacement')) {
                $replaces[$key] = $this->$method();
            } else {
                $replaces[$key] = null;
            }
        }

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

        return $this;
    }
1163764
protected function buildClass($name)
    {
        $stub = $this->replaceUserNamespace(
            parent::buildClass($name)
        );

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

        return $model ? $this->replaceModel($stub, $model) : $stub;
    }
858261
protected function replaceClasses($stub, $model, $transformer = null): string
    {
        if ($transformer) {
            $transformer = str_replace('/', '\\', $transformer);

            $namespaceTransformer = $this->rootNamespace().'\Transformers\\'.$transformer;

            if (starts_with($transformer, '\\')) {
                $stub = str_replace('NamespacedDummyTransformer', trim($transformer, '\\'), $stub);
            } else {
                $stub = str_replace('NamespacedDummyTransformer', $namespaceTransformer, $stub);
            }

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

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

            $stub = str_replace('DummyTransformer', $transformer, $stub);

            $stub = str_replace('dummyTransformer', camel_case($transformer), $stub);
        }

        $model = str_replace('/', '\\', $model);

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

        if (starts_with($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('DummyModel', $model, $stub);

        return str_replace('dummyModel', camel_case($model), $stub);
    }
773742
protected function replaceClassName(&$stub)
    {
        $className = ucwords(camel_case($this->argument('name')));

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

        return $this;
    }
592619
protected function replaceName(&$stub, $name)
    {
        $stub = str_replace('DummyTitle', $name, $stub);
        $stub = str_replace('DummyUCtitle', ucfirst(studly_case($name)), $stub);
        return $this;
    }
1291209
protected function replaceClassName(&$stub)
    {

        $className = $this->scaffoldCommandObj->getObjName('Name') . 'Controller';
        $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;
    }
1236439
protected function replaceClass($stub, $name)
    {
        $stub = parent::replaceClass($stub, $name);

        return str_replace('{{command}}', $this->option('command'), $stub);
    }
675990
protected function replaceNamespace($stub)
    {
        $stub = str_replace('DummyNamespace', $this->getNamespace(), $stub);
        $stub = str_replace('DummyRootNamespace', trim($this->laravel->getNamespace(), '\\'), $stub);

        return $stub;
    }
29509
protected function replaceSchema(&$stub)
    {
        $tables = $this->getSortedTableNames();

        $stub = str_replace(['{{columnOne}}', '{{columnTwo}}'],
            array_merge(array_map('str_singular', $tables), $tables), $stub);

        $stub = str_replace(['{{tableOne}}', '{{tableTwo}}'],
            array_merge(array_map('str_plural', $tables), $tables), $stub);

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

        return $this
            ->replaceNamespace($stub, $name)
            ->replaceModel($stub)
            ->replaceAbility($stub)
            ->replaceClass($stub, $name);
    }