Completed
Push — master ( 30a2b5...89612e )
by Axel
02:59
created

SprintCreationCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 14
dl 0
loc 25
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 13 3
A configure() 0 7 1
1
<?php
2
3
namespace Scrumban\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Question\Question;
11
12
use Scrumban\Manager\SprintManager;
13
14
class SprintCreationCommand extends ContainerAwareCommand
15
{
16
    protected function configure()
17
    {
18
        $this
19
            ->setName('scrumban:sprint:create')
20
            ->setDescription('Create a new sprint')
21
            ->addOption('begin', null, InputOption::VALUE_OPTIONAL, 'Sprint begin date')
22
            ->addOption('end', null, InputOption::VALUE_OPTIONAL, 'Sprint end date')
23
        ;
24
    }
25
    
26
    protected function execute(InputInterface $input, OutputInterface $output)
27
    {
28
        $helper = $this->getHelper('question');
29
        if(($begin = $input->getOption('begin')) === null) {
30
            $begin = $helper->ask($input, $output, new Question('Please enter the sprint begin date: '));
31
        }
32
        if(($end = $input->getOption('end')) === null) {
33
            $end = $helper->ask($input, $output, new Question('Please enter the sprint end date: '));
34
        }
35
        $sprint = $this->getContainer()->get(SprintManager::class)->createSprint(new \DateTime($begin), new \DateTime($end));
36
        
37
        $output->writeln(
38
            "<fg=white;bg=green>\n\n Sprint {$sprint->getId()} created ! It will be active from {$sprint->getBeginAt()->format('c')} to {$sprint->getEndedAt()->format('c')}\n</>\n"
39
        );
40
    }
41
}