Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
18 / 18
66.67% covered (warning)
66.67%
8 / 12
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
Planner
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
18 / 18
66.67% covered (warning)
66.67%
8 / 12
100.00% covered (success)
100.00%
4 / 4
13.70
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
 migrationId
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 pendingMigrations
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
8 / 8
60.00% covered (warning)
60.00%
3 / 5
100.00% covered (success)
100.00%
1 / 1
5.02
 duplicateMigrationIds
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
6 / 6
50.00% covered (danger)
50.00%
2 / 4
100.00% covered (success)
100.00%
1 / 1
4.12
1<?php
2
3declare(strict_types=1);
4
5namespace Celema\Quma\Migrations;
6
7final readonly class Planner
8{
9    public function __construct(
10        private DriverPolicy $driverPolicy,
11    ) {}
12
13    public function migrationId(string $namespace, string $migration): string
14    {
15        $name = basename($migration);
16
17        if ($namespace === 'default') {
18            return $name;
19        }
20
21        return $namespace . ':' . $name;
22    }
23
24    /**
25     * @param list<string> $migrations
26     * @param list<string> $appliedMigrations
27     *
28     * @return list<string>
29     */
30    public function pendingMigrations(
31        string $namespace,
32        array $migrations,
33        array $appliedMigrations,
34    ): array {
35        $pending = [];
36
37        foreach ($migrations as $migration) {
38            if (in_array($this->migrationId($namespace, $migration), $appliedMigrations, strict: true)) {
39                continue;
40            }
41
42            if (!$this->driverPolicy->supportsMigration($migration)) {
43                continue;
44            }
45
46            $pending[] = $migration;
47        }
48
49        return $pending;
50    }
51
52    /**
53     * @param list<string> $migrations
54     *
55     * @return array<string, list<string>>
56     */
57    public function duplicateMigrationIds(string $namespace, array $migrations): array
58    {
59        $pathsById = [];
60
61        foreach ($migrations as $migration) {
62            if (!$this->driverPolicy->supportsMigration($migration)) {
63                continue;
64            }
65
66            $pathsById[$this->migrationId($namespace, $migration)][] = $migration;
67        }
68
69        return array_filter($pathsById, static fn(array $paths): bool => count($paths) > 1);
70    }
71}

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.

Planner->__construct
10        private DriverPolicy $driverPolicy,
11    ) {}
Planner->duplicateMigrationIds
57    public function duplicateMigrationIds(string $namespace, array $migrations): array
58    {
59        $pathsById = [];
60
61        foreach ($migrations as $migration) {
61        foreach ($migrations as $migration) {
62            if (!$this->driverPolicy->supportsMigration($migration)) {
63                continue;
61        foreach ($migrations as $migration) {
62            if (!$this->driverPolicy->supportsMigration($migration)) {
63                continue;
64            }
65
66            $pathsById[$this->migrationId($namespace, $migration)][] = $migration;
61        foreach ($migrations as $migration) {
62            if (!$this->driverPolicy->supportsMigration($migration)) {
63                continue;
64            }
65
66            $pathsById[$this->migrationId($namespace, $migration)][] = $migration;
67        }
68
69        return array_filter($pathsById, static fn(array $paths): bool => count($paths) > 1);
70    }
Planner->migrationId
13    public function migrationId(string $namespace, string $migration): string
14    {
15        $name = basename($migration);
16
17        if ($namespace === 'default') {
18            return $name;
21        return $namespace . ':' . $name;
22    }
Planner->pendingMigrations
31        string $namespace,
32        array $migrations,
33        array $appliedMigrations,
34    ): array {
35        $pending = [];
36
37        foreach ($migrations as $migration) {
37        foreach ($migrations as $migration) {
38            if (in_array($this->migrationId($namespace, $migration), $appliedMigrations, strict: true)) {
39                continue;
42            if (!$this->driverPolicy->supportsMigration($migration)) {
43                continue;
37        foreach ($migrations as $migration) {
38            if (in_array($this->migrationId($namespace, $migration), $appliedMigrations, strict: true)) {
39                continue;
40            }
41
42            if (!$this->driverPolicy->supportsMigration($migration)) {
43                continue;
44            }
45
46            $pending[] = $migration;
37        foreach ($migrations as $migration) {
38            if (in_array($this->migrationId($namespace, $migration), $appliedMigrations, strict: true)) {
39                continue;
40            }
41
42            if (!$this->driverPolicy->supportsMigration($migration)) {
43                continue;
44            }
45
46            $pending[] = $migration;
47        }
48
49        return $pending;
50    }
{closure:/workspace/celema/quma/src/Migrations/Planner.php:69-69}
69        return array_filter($pathsById, static fn(array $paths): bool => count($paths) > 1);