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%
2 / 2
100.00% covered (success)
100.00%
2 / 2
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%
2 / 2
100.00% covered (success)
100.00%
2 / 2
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
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\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')]
15#[Opt('--conn', 'Connection to use', value: 'name')]
16#[Opt('--stacktrace', 'Show stack traces for failing table creation')]
17final class CreateMigrationsTable
18{
19    private readonly Environment $env;
20
21    /** @param array<non-empty-string, Connection>|Connection $conn */
22    public function __construct(array|Connection $conn, array $options = [])
23    {
24        $this->env = new Environment($conn, $options);
25    }
26
27    public function __invoke(Io $io): int
28    {
29        $env = $this->env;
30
31        return new MetadataTable($env, $io)->create($env->db);
32    }
33}