Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| MigrationVersion | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| run | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php declare(strict_types=1); |
| 2 | /* |
| 3 | * This file is part of Aplus Framework Dev Commands Library. |
| 4 | * |
| 5 | * (c) Natan Felles <natanfelles@gmail.com> |
| 6 | * |
| 7 | * For the full copyright and license information, please view the LICENSE |
| 8 | * file that was distributed with this source code. |
| 9 | */ |
| 10 | namespace Framework\CLI\Commands; |
| 11 | |
| 12 | use Framework\CLI\CLI; |
| 13 | use Framework\CLI\Command; |
| 14 | use Framework\MVC\App; |
| 15 | |
| 16 | /** |
| 17 | * Class MigrationVersion. |
| 18 | * |
| 19 | * @package dev-commands |
| 20 | */ |
| 21 | class MigrationVersion extends Command |
| 22 | { |
| 23 | protected string $description = 'Shows last migration version name.'; |
| 24 | protected string $migratorInstance = 'default'; |
| 25 | |
| 26 | public function run() : void |
| 27 | { |
| 28 | // @phpstan-ignore-next-line |
| 29 | $this->migratorInstance = $this->getConsole()->getOption('instance') ?? 'default'; |
| 30 | // @phpstan-ignore-next-line |
| 31 | $name = App::migrator($this->migratorInstance)->getLastMigrationName(); |
| 32 | if ($name !== null) { |
| 33 | CLI::write($name); |
| 34 | return; |
| 35 | } |
| 36 | CLI::write('No migration.'); |
| 37 | } |
| 38 | } |