Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
20 / 20 |
|
100.00% |
12 / 12 |
|
66.67% |
6 / 9 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| MetadataTable | |
100.00% |
20 / 20 |
|
100.00% |
12 / 12 |
|
66.67% |
6 / 9 |
|
100.00% |
2 / 2 |
8.81 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| create | |
100.00% |
19 / 19 |
|
100.00% |
11 / 11 |
|
62.50% |
5 / 8 |
|
100.00% |
1 / 1 |
7.90 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celema\Quma\Migrations; |
| 6 | |
| 7 | use Celema\Console\Io; |
| 8 | use Celema\Quma\Database; |
| 9 | use Celema\Quma\Environment; |
| 10 | use Throwable; |
| 11 | |
| 12 | final readonly class MetadataTable |
| 13 | { |
| 14 | public function __construct( |
| 15 | private Environment $env, |
| 16 | private Io $io, |
| 17 | ) {} |
| 18 | |
| 19 | public function create(Database $db): int |
| 20 | { |
| 21 | $env = $this->env; |
| 22 | $io = $this->io; |
| 23 | $driver = $db->getPdoDriver(); |
| 24 | $ddl = $env->getMigrationsTableDDL(); |
| 25 | |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 27 | $io->error("PDO driver '%s' not supported. Aborting", $driver); |
| 28 | |
| 29 | return 1; |
| 30 | } |
| 31 | |
| 32 | if ($env->checkIfMigrationsTableExists($db)) { |
| 33 | $io->error("Table '%s' already exists. Aborting", $env->table); |
| 34 | |
| 35 | return 1; |
| 36 | } |
| 37 | |
| 38 | try { |
| 39 | $db->execute($ddl)->run(); |
| 40 | $io->line("<bright-green>Success</bright-green>: Created table '%s'", $env->table); |
| 41 | |
| 42 | return 0; |
| 43 | } catch (Throwable $e) { |
| 44 | $io->error("Error: While trying to create table '%s'", $env->table); |
| 45 | $io->stderr()->line('%s', $e->getMessage()); |
| 46 | |
| 47 | if ($env->showStacktrace) { |
| 48 | $io->stderr()->line('%s', $e->getTraceAsString()); |
| 49 | } |
| 50 | |
| 51 | return 1; |
| 52 | } |
| 53 | } |
| 54 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 15 | private Environment $env, |
| 16 | private Io $io, |
| 17 | ) {} |
| 19 | public function create(Database $db): int |
| 20 | { |
| 21 | $env = $this->env; |
| 22 | $io = $this->io; |
| 23 | $driver = $db->getPdoDriver(); |
| 24 | $ddl = $env->getMigrationsTableDDL(); |
| 25 | |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 27 | $io->error("PDO driver '%s' not supported. Aborting", $driver); |
| 28 | |
| 29 | return 1; |
| 19 | public function create(Database $db): int |
| 20 | { |
| 21 | $env = $this->env; |
| 22 | $io = $this->io; |
| 23 | $driver = $db->getPdoDriver(); |
| 24 | $ddl = $env->getMigrationsTableDDL(); |
| 25 | |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 32 | if ($env->checkIfMigrationsTableExists($db)) { |
| 33 | $io->error("Table '%s' already exists. Aborting", $env->table); |
| 34 | |
| 35 | return 1; |
| 19 | public function create(Database $db): int |
| 20 | { |
| 21 | $env = $this->env; |
| 22 | $io = $this->io; |
| 23 | $driver = $db->getPdoDriver(); |
| 24 | $ddl = $env->getMigrationsTableDDL(); |
| 25 | |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 32 | if ($env->checkIfMigrationsTableExists($db)) { |
| 38 | try { |
| 39 | $db->execute($ddl)->run(); |
| 40 | $io->line("<bright-green>Success</bright-green>: Created table '%s'", $env->table); |
| 41 | |
| 42 | return 0; |
| 19 | public function create(Database $db): int |
| 20 | { |
| 21 | $env = $this->env; |
| 22 | $io = $this->io; |
| 23 | $driver = $db->getPdoDriver(); |
| 24 | $ddl = $env->getMigrationsTableDDL(); |
| 25 | |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 27 | $io->error("PDO driver '%s' not supported. Aborting", $driver); |
| 28 | |
| 29 | return 1; |
| 19 | public function create(Database $db): int |
| 20 | { |
| 21 | $env = $this->env; |
| 22 | $io = $this->io; |
| 23 | $driver = $db->getPdoDriver(); |
| 24 | $ddl = $env->getMigrationsTableDDL(); |
| 25 | |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 32 | if ($env->checkIfMigrationsTableExists($db)) { |
| 33 | $io->error("Table '%s' already exists. Aborting", $env->table); |
| 34 | |
| 35 | return 1; |
| 19 | public function create(Database $db): int |
| 20 | { |
| 21 | $env = $this->env; |
| 22 | $io = $this->io; |
| 23 | $driver = $db->getPdoDriver(); |
| 24 | $ddl = $env->getMigrationsTableDDL(); |
| 25 | |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 26 | if ($ddl === false || !new DriverPolicy($driver)->isKnown()) { |
| 32 | if ($env->checkIfMigrationsTableExists($db)) { |
| 38 | try { |
| 39 | $db->execute($ddl)->run(); |
| 40 | $io->line("<bright-green>Success</bright-green>: Created table '%s'", $env->table); |
| 41 | |
| 42 | return 0; |
| 43 | } catch (Throwable $e) { |
| 44 | $io->error("Error: While trying to create table '%s'", $env->table); |
| 45 | $io->stderr()->line('%s', $e->getMessage()); |
| 46 | |
| 47 | if ($env->showStacktrace) { |
| 48 | $io->stderr()->line('%s', $e->getTraceAsString()); |
| 49 | } |
| 50 | |
| 51 | return 1; |
| 51 | return 1; |
| 52 | } |
| 53 | } |
| 43 | } catch (Throwable $e) { |
| 44 | $io->error("Error: While trying to create table '%s'", $env->table); |
| 45 | $io->stderr()->line('%s', $e->getMessage()); |
| 46 | |
| 47 | if ($env->showStacktrace) { |
| 51 | return 1; |
| 52 | } |
| 53 | } |