Completed
Push — master ( 5ff3e1...46578f )
by Jonathan
12s
created

RollupCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 1
A configure() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Tools\Console\Command;
6
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use function sprintf;
10
11
class RollupCommand extends AbstractCommand
12
{
13 10
    protected function configure() : void
14
    {
15 10
        parent::configure();
16
17
        $this
18 10
            ->setName('migrations:rollup')
19 10
            ->setAliases(['rollup'])
20 10
            ->setDescription('Rollup migrations by deleting all tracked versions and insert the one version that exists.')
21 10
            ->setHelp(<<<EOT
22 10
The <info>%command.name%</info> command rolls up migrations by deleting all tracked versions and
23
inserts the one version that exists that was created with the <info>migrations:dump-schema</info> command.
24
25
    <info>%command.full_name%</info>
26
27
To dump your schema to a migration version you can use the <info>migrations:dump-schema</info> command.
28
EOT
29
            )
30
        ;
31 10
    }
32
33 2
    public function execute(
34
        InputInterface $input,
35
        OutputInterface $output
36
    ) : void {
37 2
        $version = $this->dependencyFactory
38 2
            ->getRollup()->rollup();
39
40 2
        $output->writeln(sprintf(
41 2
            'Rolled up migrations to version <info>%s</info>',
42 2
            $version->getVersion()
43
        ));
44 2
    }
45
}
46