Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Commands | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| get | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celema\Quma; |
| 6 | |
| 7 | use Celema\Quma\Commands\Add; |
| 8 | use Celema\Quma\Commands\CreateMigrationsTable; |
| 9 | use Celema\Quma\Commands\Migrations; |
| 10 | use Celema\Quma\Contract\MigrationFactory; |
| 11 | use Closure; |
| 12 | |
| 13 | /** @api */ |
| 14 | class Commands |
| 15 | { |
| 16 | /** |
| 17 | * The migration commands as lazy factories, for a console Runner: |
| 18 | * `new Runner(Commands::get($conn))` or `$runner->add(...)`. |
| 19 | * |
| 20 | * @param array<non-empty-string, Connection>|Connection $conn |
| 21 | * @param array<array-key, mixed> $options |
| 22 | * |
| 23 | * @return array<class-string, Closure(): object> |
| 24 | */ |
| 25 | public static function get( |
| 26 | array|Connection $conn, |
| 27 | array $options = [], |
| 28 | ?MigrationFactory $migrationFactory = null, |
| 29 | ): array { |
| 30 | return [ |
| 31 | Add::class => static fn(): Add => new Add($conn, $options), |
| 32 | CreateMigrationsTable::class => static fn(): CreateMigrationsTable => new CreateMigrationsTable( |
| 33 | $conn, |
| 34 | $options, |
| 35 | ), |
| 36 | Migrations::class => static fn(): Migrations => new Migrations($conn, $options, $migrationFactory), |
| 37 | ]; |
| 38 | } |
| 39 | } |