Replace the class name for the given stub.

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

        return str_replace('$dummy', '$' . strtolower($this->getNameInput()), $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);
    }
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;
    }
166740
protected function replaceNameStrings(&$stub, $name)
    {
        $table = str_plural(ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', str_replace($this->getNamespace($name).'\\', '', $name))), '_'));

        $stub = str_replace('DummyTable', $table, $stub);
        $stub = str_replace('dummy_class', strtolower(str_replace($this->getNamespace($name).'\\', '', $name)), $stub);

        return $this;
    }
1302776
protected function buildClass($name = null)
    {
        $stub = $this->files->get($this->getStub());
        return $this->replacePivotTableName($stub)
            ->replaceSchema($stub)
            ->replaceClass($stub, $name);
    }
201467
protected function replaceSchema(&$stub)
    {
        $schema = '';
        if (!$this->optionPlain()) {
            if ($schema = $this->optionSchema()) {
                $schema = (new SchemaParser)->parse($schema);
            }

            $schema = (new SyntaxBuilder)->create($schema, $this->meta);
        }

        $stub = str_replace(['{{schema_up}}', '{{schema_down}}'], $schema, $stub);

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

        return $this;
    }
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);
    }
1353976
protected function replaceUserNamespace($stub)
    {
        $model = $this->userProviderModel();

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

        return str_replace(
            $this->rootNamespace().'User',
            $model,
            $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;
    }
1089914
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        return $this
            ->replaceNamespace($stub, $name)
            ->replaceModel($stub)
            ->replaceAbility($stub)
            ->replaceClass($stub, $name);
    }
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);
    }
592619
protected function replaceName(&$stub, $name)
    {
        $stub = str_replace('DummyTitle', $name, $stub);
        $stub = str_replace('DummyUCtitle', ucfirst(studly_case($name)), $stub);
        return $this;
    }
19743
protected function replaceNamespace(&$stub, $name)
    {
        $stub = str_replace('{{namespace}}', $this->getNamespace($name), $stub);

        $stub = str_replace('{{rootNamespace}}', $this->container->getNamespace(), $stub);

        return $this;
    }
98353
protected function replaceClassNameSingular(&$stub, $name)
    {
        $stub = str_replace(
            '[[DummyClassNameSingular]]', Str::singular($this->getNameInput()), $stub
        );

        return $this;
    }
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);
    }
181202
protected function buildClass($name)
    {
        $stub = parent::buildClass($name);

        return $this->replaceType($stub, $name);
    }