Completed
Push — master ( 357eb6...5eff20 )
by dima
02:34
created

SeedBuildCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

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