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

ListCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 2
dl 0
loc 10
ccs 0
cts 9
cp 0
crap 6
rs 10
c 0
b 0
f 0
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