Replace the scope for the given stub.

@param string $stub
@param string $scope

@return $this
979326
protected function replaceScope(string &$stub, string $scope)
    {

        if (strlen($scope) > 0)
            $stub = str_replace("'public'", "'$scope'", $stub);

        return $this;
    }
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);
    }
1354874
protected function replaceFieldMaxLengthName(&$stub, $maxLength)
    {
        $stub = $this->strReplace('max_length', $this->getFieldMaxLengthName($maxLength), $stub);

        return $this;
    }
934429
protected function extendStub($stub)
    {
        /** @var \Illuminate\Filesystem\Filesystem $files */
        $files = App::make('Illuminate\Filesystem\Filesystem');
        $content = $files->get(__DIR__.DIRECTORY_SEPARATOR.'stubs'.DIRECTORY_SEPARATOR.'command.stub');

        $replacements = [
            'use Illuminate\Console\Command' => "use Indatus\\Dispatcher\\Scheduling\\ScheduledCommand;\n".
                "use Indatus\\Dispatcher\\Scheduling\\Schedulable;\n".
                "use Indatus\\Dispatcher\\Drivers\\".ucwords(Config::get('dispatcher::driver'))."\\Scheduler",
            'extends Command {' => 'extends ScheduledCommand {',
            'parent::__construct();' => $content,
        ];

        $stub = str_replace(array_keys($replacements), array_values($replacements), $stub);

        return $stub;
    }
781631
protected function replaceClass($stub, $name)
    {
        $stub = str_replace('{{class}}',$this->parseName($name), $stub);
        return $stub;
    }
727484
protected function addNamespace($stub)
	{
		if ( ! is_null($namespace = $this->input->getOption('namespace')))
		{
			return str_replace('{{namespace}}', ' namespace '.$namespace.';', $stub);
		}
		else
		{
			return str_replace('{{namespace}}', '', $stub);
		}
	}
773742
protected function replaceClassName(&$stub)
    {
        $className = ucwords(camel_case($this->argument('name')));

        $stub = str_replace('{{class}}', $className, $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;
    }
1336507
protected function replaceUserNamespace($stub)
    {
        $config = $this->container['config'];

        //
        $namespaceModel = $config->get('auth.providers.users.model', 'App\Models\User');

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

        //
        $stub = str_replace('{{fullUserModel}}', $namespaceModel, $stub);

        return str_replace('{{userModel}}', $model, $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;
    }
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;
    }
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;
    }
654798
protected function replaceNamespace(&$stub, $name)
    {
        $stub = str_replace(
            ['DummyNamespace', 'DummyRootNamespace', 'NamespacedDummyUserModel'],
            [$this->getNamespace($name), $this->rootNamespace(), $this->userProviderModel()],
            $stub
        );

        return $this;
    }
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);
    }
431036
protected function replaceFieldRequired(&$stub, $required)
    {
        $stub = $this->strReplace('required_field', $this->getFieldRequired($required), $stub);

        return $this;
    }
1135964
public function update(Queries\IScope $scope)
    {
        if ($this->scope === $scope) {
            return $this;
        }

        return new self($scope);
    }
198896
protected function replaceBaseRepositoryClass(&$stub, $name)
    {
        $baseClass = str_replace($this->getNamespace($name) . '\\', '', $name);
        $stub      = str_replace('BaseRepositoryClass', $baseClass, $stub);

        return $this;
    }