Completed
Push — master ( aaccd5...c6e65b )
by Jonathan
10s
created

GenerateChangelogCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
ccs 30
cts 30
cp 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 7 1
A __construct() 0 5 1
B configure() 0 28 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ChangelogGenerator\Command;
6
7
use ChangelogGenerator\ChangelogGenerator;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class GenerateChangelogCommand extends Command
14
{
15
    /** @var ChangelogGenerator */
16
    private $changelogGenerator;
17
18 1
    public function __construct(ChangelogGenerator $changelogGenerator)
19
    {
20 1
        $this->changelogGenerator = $changelogGenerator;
21
22 1
        parent::__construct();
23 1
    }
24
25 1
    protected function configure() : void
26
    {
27
        $this
28 1
            ->setName('generate')
29 1
            ->setDescription('Generate a changelog markdown document from a GitHub milestone.')
30 1
            ->setHelp(<<<EOT
31 1
The <info>%command.name%</info> command generates a changelog markdown document from a GitHub milestone:
32
33
    <info>%command.full_name% --user=doctrine --repository=migrations --milestone=2.0</info>
34
EOT
35
            )
36 1
            ->addOption(
37 1
                'user',
38 1
                null,
39 1
                InputOption::VALUE_REQUIRED,
40 1
                'User that owns the repository.'
41
            )
42 1
            ->addOption(
43 1
                'repository',
44 1
                null,
45 1
                InputOption::VALUE_REQUIRED,
46 1
                'The repository owned by the user.'
47
            )
48 1
            ->addOption(
49 1
                'milestone',
50 1
                null,
51 1
                InputOption::VALUE_REQUIRED,
52 1
                'The milestone to build the changelog for.'
53
            )
54
        ;
55 1
    }
56
57 1
    protected function execute(InputInterface $input, OutputInterface $output) : void
58
    {
59 1
        $user       = $input->getOption('user');
60 1
        $repository = $input->getOption('repository');
61 1
        $milestone  = $input->getOption('milestone');
62
63 1
        $this->changelogGenerator->generate($user, $repository, $milestone, $output);
64 1
    }
65
}
66