SeedBuildCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
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 SeedBuildCommand extends Command{
17
18
    protected function configure(){
19
	$this->setName('seed:build')
20
		->setDescription('Create seeds data')
21
		->setDefinition(
22
			new InputDefinition(array(
23
		    new InputOption('class', 'c', InputOption::VALUE_REQUIRED),
24
		    new InputOption('amount', 'a', InputOption::VALUE_OPTIONAL)
25
			))
26
	);
27
    }
28
29
    protected function execute(InputInterface $input, OutputInterface $output){
30
31
	if(!$class = $input->getOption('class')){
32
	    $output->writeln("Class Model not set");
33
	    return;
34
	}
35
36
	$number = $input->getOption('amount');
37
	$class::build($number > 1 ? $number : 1);
38
	$output->writeln(sprintf("Seed %s amount %s create success!", $class, $number));
39
    }
40
}
41