ListCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

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