The class_basename function returns the class name of the given class with the class's namespace removed:
<?php $class = class_basename('Foo\Bar\Baz');
<?php         $contents = File::get(__DIR__ . '/../stubs/factory.stub');

        $contents = str_replace('{{ factoryNamespace }}', $factoryNamespace, $contents);

        $contents = str_replace('{{ namespacedModel }}', $modelClass, $contents);

        $contents = str_replace('{{ model }}', class_basename($modelClass), $contents);

        $contents = str_replace('            //', trim($definition, PHP_EOL), $contents);



        File::put($path, $contents);