Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Commands
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 get
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Celema\Quma;
6
7use Celema\Quma\Commands\Add;
8use Celema\Quma\Commands\CreateMigrationsTable;
9use Celema\Quma\Commands\Migrations;
10use Celema\Quma\Contract\MigrationFactory;
11use Closure;
12
13/** @api */
14class 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}