DoctrineMigration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 17
ccs 0
cts 10
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A preUp() 0 5 1
A preDown() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\Doctrine\Migrations;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
/**
11
 * This is the base class for all App Migrations.
12
 * It ensures that the Migrations are executed against the proper database and skipped for all others.
13
 */
14
abstract class DoctrineMigration extends AbstractMigration
15
{
16
    public function preUp(Schema $schema): void
17
    {
18
        $parameters = $this->connection->getParams();
19
        $this->skipIf($parameters['dbname'] != $this->getDbName(),
20
            "This is the other DB\'s migration, pass a correct --em parameter");
21
    }
22
23
    public function preDown(Schema $schema): void
24
    {
25
        $parameters = $this->connection->getParams();
26
        $this->skipIf($parameters['dbname'] != $this->getDbName(),
27
            "This is the other DB\'s migration, pass a correct --em parameter");
28
    }
29
30
    protected abstract function getDbName(): string;
31
}