SeedResetCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
namespace Frameworkless\Console\Commands;
3
4
use Symfony\Component\Console\Command\Command;
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
use Symfony\Component\Console\Input\InputDefinition;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Input\InputArgument;
10
11
/**
12
 * Description of HelloWorldCommand
13
 *
14
 * @author Dmitriy
15
 */
16
class SeedResetCommand extends Command{
17
18
    protected function configure(){
19
	$this->setName('seed:reset')
20
		->setDescription('Reset all seeds data')
21
		->setDefinition(
22
			new InputDefinition(array(
23
		    new InputOption('class', 'c', InputOption::VALUE_REQUIRED)
24
			))
25
	);
26
    }
27
28
    protected function execute(InputInterface $input, OutputInterface $output){
29
30
	if(!$class = $input->getOption('class')){
31
	    $output->writeln("Class Model not set");
32
	    return;
33
	}
34
35
	if($class::reset()){
36
	    $output->writeln(sprintf("Seed %s reset success!", $class));
37
	} else
38
	    $output->writeln("Command seed:reset fail to execute!");
39
    }
40
}
41