<commit_before><?php namespace Modules\Workshop\Console;

use Illuminate\Console\Command;
use Modules\Workshop\Scaffold\Module\ModuleScaffold;

class ModuleScaffoldCommand extends Command
{
    protected $name = 'asgard:module:scaffold';
    protected $description = 'Scaffold a new module';
    /**
     * @var array
     */
    protected $entities = [];
    /**
     * @var array
     */
    protected $valueObjects = [];
    /**
     * @var string The type of entities to generate [Eloquent or Doctrine]
     */
    protected $entityType;
    /**
     * @var ModuleScaffold
     */
    private $moduleScaffold;

    public function __construct(ModuleScaffold $moduleScaffold)
    {
        parent::__construct();
        $this->moduleScaffold = $moduleScaffold;
    }

    /**
     *
     */
    public function fire()
    {
        $moduleName = $this->ask('Please enter the module name in the following format: vendor/name');
        list($vendor, $name) = $this->separateVendorAndName($moduleName);

        $this->checkForModuleUniqueness($name);

        $this->askForEntities();
        $this->askForValueObjects();

        $this->moduleScaffold
            ->vendor($vendor)
            ->name($name)
            ->setEntityType($this->entityType)
            ->withEntities($this->entities)
            ->withValueObjects($this->valueObjects)
            ->scaffold();

        $this->info('Module generated and is ready to be used.');
    }

    /**
     *
     */
    private function askForEntities()
    {
        // $this->entityType = $this->choice('Do you want to use Eloquent or Doctrine ?', ['Eloquent','Doctrine'], 0); # this->choice broken in laravel
        $this->entityType = 'Eloquent';
        do {
            $entity = $this->ask('Enter entity name. Leaving option empty will continue script.', '<none>');
            if (!empty($entity) && $entity !== '<none>') {
                $this->entities[] = ucfirst($entity);
            }
        } while ($entity !== '<none>');
    }

    /**
     *
     */
    private function askForValueObjects()<commit_msg>Use the anticipate method instead of choice()<commit_after><?php namespace Modules\Workshop\Console;

use Illuminate\Console\Command;
use Modules\Workshop\Scaffold\Module\ModuleScaffold;

class ModuleScaffoldCommand extends Command
{
    protected $name = 'asgard:module:scaffold';
    protected $description = 'Scaffold a new module';
    /**
     * @var array
     */
    protected $entities = [];
    /**
     * @var array
     */
    protected $valueObjects = [];
    /**
     * @var string The type of entities to generate [Eloquent or Doctrine]
     */
    protected $entityType;
    /**
     * @var ModuleScaffold
     */
    private $moduleScaffold;

    public function __construct(ModuleScaffold $moduleScaffold)
    {
        parent::__construct();
        $this->moduleScaffold = $moduleScaffold;
    }

    /**
     *
     */
    public function fire()
    {
        $moduleName = $this->ask('Please enter the module name in the following format: vendor/name');
        list($vendor, $name) = $this->separateVendorAndName($moduleName);

        $this->checkForModuleUniqueness($name);

        $this->askForEntities();
        $this->askForValueObjects();

        $this->moduleScaffold
            ->vendor($vendor)
            ->name($name)
            ->setEntityType($this->entityType)
            ->withEntities($this->entities)
            ->withValueObjects($this->valueObjects)
            ->scaffold();

        $this->info('Module generated and is ready to be used.');
    }

    /**
     *
     */
    private function askForEntities()
    {
        $this->entityType = $this->anticipate('Do you want to use Eloquent or Doctrine ?', ['Eloquent','Doctrine'], 'Eloquent');

        do {
            $entity = $this->ask('Enter entity name. Leaving option empty will continue script.', '<none>');
            if (!empty($entity) && $entity !== '<none>') {
                $this->entities[] = ucfirst($entity);
            }
        } while ($entity !== '<none>');
    }

    /**
     *
     */
    private function askForValueObjects()
{'fraction_non_alphanumeric': 0.14340898116851764, 'fraction_numerical': 0.00024142926122646064, 'mean_word_length': 2.3117505995203835, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 53, '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': '5542957', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1186, 'n_words': 261}