Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Log
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
3
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
 applied
100.00% covered (success)
100.00%
7 / 7
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
 record
100.00% covered (success)
100.00%
6 / 6
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 Celemas\Quma\Migrations;
6
7use Celemas\Quma\Database;
8use Celemas\Quma\Environment;
9
10final readonly class Log
11{
12    public function __construct(
13        private Environment $env,
14        private Planner $planner,
15    ) {}
16
17    /** @return list<string> */
18    public function applied(Database $db): array
19    {
20        $table = $this->env->table;
21        $column = $this->env->columnMigration;
22        $migrations = $db->execute("SELECT {$column} AS migration FROM {$table};")->all();
23
24        return array_map(
25            static fn(array $migration): string => (string) $migration['migration'],
26            $migrations,
27        );
28    }
29
30    public function record(Database $db, string $namespace, string $migration): void
31    {
32        $table = $this->env->table;
33        $column = $this->env->columnMigration;
34
35        $db->execute(
36            "INSERT INTO {$table} ({$column}) VALUES (:migration)",
37            ['migration' => $this->planner->migrationId($namespace, $migration)],
38        )->run();
39    }
40}

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

Log->__construct
13        private Environment $env,
14        private Planner $planner,
15    ) {}
Log->applied
18    public function applied(Database $db): array
19    {
20        $table = $this->env->table;
21        $column = $this->env->columnMigration;
22        $migrations = $db->execute("SELECT {$column} AS migration FROM {$table};")->all();
23
24        return array_map(
25            static fn(array $migration): string => (string) $migration['migration'],
26            $migrations,
27        );
28    }
Log->record
30    public function record(Database $db, string $namespace, string $migration): void
31    {
32        $table = $this->env->table;
33        $column = $this->env->columnMigration;
34
35        $db->execute(
36            "INSERT INTO {$table} ({$column}) VALUES (:migration)",
37            ['migration' => $this->planner->migrationId($namespace, $migration)],
38        )->run();
39    }
{closure:/workspace/celemas/quma/src/Migrations/Log.php:25-25}
25            static fn(array $migration): string => (string) $migration['migration'],