# ModelCommand

class ModelCommand extends Command

## Methods

`protected` | `` | `configure()` | No description |
`protected` | `` | `execute(InputInterface $input, OutputInterface $output)` | No description |

## Details

at line 16

### `configure()`

`protected configure()`
at line 25

### `execute()`

`protected execute(InputInterface $input, OutputInterface $output)`

#### Parameters

`InputInterface` | `$input` |
`OutputInterface` | `$output` |

## Source code

    <?php

    	namespace Command;

    	set_time_limit(0);

    	use Symfony\Component\Console\Command\Command as Comando;
    	use Symfony\Component\Console\Input\InputInterface;
    	use Symfony\Component\Console\Output\OutputInterface;
    	use Symfony\Component\Console\Input\InputArgument;
    	use App\Khan\Component\Hooks\Hooks as Hooks;
    	use Command\KhanCommand as KhanCommand;

    	class ModelCommand extends Comando {

    	    protected function configure(){

    	        $this->setName('model')
    	             ->addArgument('model-name', InputArgument::OPTIONAL, 'Qual o nome do model?')
            		 ->setDescription('New model.')
            		 ->setHelp('New model in project...');

    	    }

    	    protected function execute(InputInterface $input, OutputInterface $output){

    	    	$model = ($input->getArgument('model-name')) ? $input->getArgument('model-name') : false;
    	    	$botLearning = Bot\Bot::init('models');
    			$modelUses = $botLearning::loadUses();

    	    	if($model){

    	    		$folder = "app/models/{$model}.php";
    	    		$folderOrigin = __DIR__. "/storage/model/model.php";

    	    		$make = Hooks::create($folder, Hooks::replace($folderOrigin, [
    					"modelName" => $model,
    					"usedss" => array_reduce($modelUses, function($ant, $atual){
    						return $ant . "\n	use $atual;";
    					}, "")
    				]));

    	    		if($make){

    	    			$output->writeln('<info>Model '.$model.' foi criado com sucesso!!</info>');

    				}

    	    	}else{

    	    		$output->writeln('<fg=red>Error to create model</>');

    	    	}

    	    }

    	}