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

ListCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 9
c 0
b 0
f 0
dl 0
loc 15
ccs 0
cts 7
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 2
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