Passed
Push — master ( 227314...d8a269 )
by Alexander
14:02
created

ListCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 20
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 2
A configure() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Command\Migration;
6
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Yiisoft\Yii\Console\ExitCode;
10
11
final class ListCommand extends BaseMigrationCommand
12
{
13
    protected static $defaultName = 'migrate/list';
14
15
    public function configure(): void
16
    {
17
        $this
18
            ->setDescription('Print list of all migrations');
19
    }
20
21
    protected function execute(InputInterface $input, OutputInterface $output): int
22
    {
23
        $list = $this->findMigrations($output);
24
25
        foreach ($list as $migration) {
26
            $state = $migration->getState();
27
            $output->writeln('<fg=cyan>' . $state->getName() . '</> '
28
                . '<fg=yellow>[' . (static::MIGRATION_STATUS[$state->getStatus()] ?? '?') . ']</>');
29
        }
30
        return ExitCode::OK;
31
    }
32
}
33