Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
CreateMigrationsTable
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
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
 __invoke
100.00% covered (success)
100.00%
2 / 2
n/a
0 / 0
n/a
0 / 0
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Celema\Quma\Commands;
6
7use Celema\Console\Command;
8use Celema\Console\Io;
9use Celema\Console\Opt;
10use Celema\Quma\Connection;
11use Celema\Quma\Environment;
12use Celema\Quma\Migrations\MetadataTable;
13
14#[Command('db:create-migrations-table', 'Creates a migrations table', group: 'Database')]
15final class CreateMigrationsTable
16{
17    /**
18     * @param array<non-empty-string, Connection>|Connection $connections
19     * @param array<array-key, mixed> $options
20     */
21    public function __construct(
22        private readonly array|Connection $connections,
23        private readonly array $options = [],
24    ) {}
25
26    public function __invoke(
27        Io $io,
28        #[Opt('Connection to use', value: 'name')]
29        string $conn = 'default',
30        #[Opt('Show stack traces for failing table creation')]
31        bool $stacktrace = false,
32    ): int {
33        $env = new Environment($this->connections, $this->options, $conn, $stacktrace);
34
35        return new MetadataTable($env, $io)->create($env->db);
36    }
37}