<commit_before><?php

namespace WouterJ\EloquentBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Illuminate\Database\Seeder as IlluminateSeeder;
use WouterJ\EloquentBundle\Seeder;

class SeederMakeCommand extends Command
{
    private $stubPath;
    /** @var string */
    private $appDir;
    /** @var array */
    private $bundles;

    public function __construct($appDir, array $bundles)
    {
        parent::__construct();

        $this->appDir = $appDir;
        $this->bundles = $bundles;
    }

    protected function configure()
    {
        $this->setName('eloquent:make:seeder')
            ->setDescription('Create a new seeder class')
            ->addOption('target', null, InputOption::VALUE_REQUIRED, 'The target directory')
            ->addArgument('name', InputArgument::REQUIRED, 'The name of the seeder class')
        ;
    }

    protected function initialize(InputInterface $input, OutputInterface $output)
    {
        $this->stubPath = dirname((new \ReflectionClass(IlluminateSeeder::class))->getFileName()).'/Console/Seeds/stubs';
    }

    protected function execute(InputInterface $i, OutputInterface $o)
    {
        $name = $i->getArgument('name');
        $path = $i->getOption('target') ?: $this->getPath($name);

        if (file_exists($path)) {
            $o->writeln('<error>Seeder already exists!</>');

            return 1;
        }

        if (!is_dir(dirname($path))) {
            mkdir(dirname($path), 0777, true);
        }

        file_put_contents($path, $this->buildClass($name));
    }

    private function buildClass($name)
    {
        $lastPos = strrpos($name, '\\');
        $namespace = $lastPos ? substr($name, 0, $lastPos) : false;
        $class = substr($name, $lastPos + 1);

        $stub = file_get_contents($this->stubPath.'/seeder.stub');
        $stub = str_replace('DummyClass', $class, $stub);<commit_msg>Fixing Seeder Command class naming convention<commit_after><?php

namespace WouterJ\EloquentBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Illuminate\Database\Seeder as IlluminateSeeder;
use WouterJ\EloquentBundle\Seeder;

class SeederMakeCommand extends Command
{
    private $stubPath;
    /** @var string */
    private $appDir;
    /** @var array */
    private $bundles;

    public function __construct($appDir, array $bundles)
    {
        parent::__construct();

        $this->appDir = $appDir;
        $this->bundles = $bundles;
    }

    protected function configure()
    {
        $this->setName('eloquent:make:seeder')
            ->setDescription('Create a new seeder class')
            ->addOption('target', null, InputOption::VALUE_REQUIRED, 'The target directory')
            ->addArgument('name', InputArgument::REQUIRED, 'The name of the seeder class')
        ;
    }

    protected function initialize(InputInterface $input, OutputInterface $output)
    {
        $this->stubPath = dirname((new \ReflectionClass(IlluminateSeeder::class))->getFileName()).'/Console/Seeds/stubs';
    }

    protected function execute(InputInterface $i, OutputInterface $o)
    {
        $name = $i->getArgument('name');
        $path = $i->getOption('target') ?: $this->getPath($name);

        if (file_exists($path)) {
            $o->writeln('<error>Seeder already exists!</>');

            return 1;
        }

        if (!is_dir(dirname($path))) {
            mkdir(dirname($path), 0777, true);
        }

        file_put_contents($path, $this->buildClass($name));
    }

    private function buildClass($name)
    {
        $lastPos = strrpos($name, '\\');
        $namespace = $lastPos ? substr($name, 0, $lastPos) : false;
        $class = substr($name, $lastPos);

        $stub = file_get_contents($this->stubPath.'/seeder.stub');
        $stub = str_replace('DummyClass', $class, $stub);
{'fraction_non_alphanumeric': 0.14302544769085768, 'fraction_numerical': 0.003063147973609802, 'mean_word_length': 3.1054158607350097, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4991034', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1267, 'n_words': 245}