Passed
Pull Request — master (#148)
by Rustam
12:16
created

ListCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
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
    protected static $defaultDescription = 'Prints list of all migrations';
15
16
    protected function execute(InputInterface $input, OutputInterface $output): int
17
    {
18
        $list = $this->findMigrations($output);
19
20
        foreach ($list as $migration) {
21
            $state = $migration->getState();
22
            $output->writeln('<fg=cyan>' . $state->getName() . '</> '
23
                . '<fg=yellow>[' . (self::MIGRATION_STATUS[$state->getStatus()] ?? '?') . ']</>');
24
        }
25
        return ExitCode::OK;
26
    }
27
}
28