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

SeedBuildCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 1
A execute() 0 12 3
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