Version20210411114720   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
eloc 26
c 0
b 0
f 0
dl 0
loc 54
ccs 0
cts 33
cp 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 4 1
A createAndUpdateDate() 0 4 1
A createHistoryTable() 0 11 1
A createPlayerTable() 0 13 1
A getDescription() 0 3 1
A down() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Game\Infrastructure\Repository\DoctrineMigrations;
6
7
use Doctrine\DBAL\Schema\Schema;
0 ignored issues
show
Bug introduced by
The type Doctrine\DBAL\Schema\Schema was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Doctrine\DBAL\Schema\Table;
0 ignored issues
show
Bug introduced by
The type Doctrine\DBAL\Schema\Table was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Doctrine\DBAL\Types\Types;
0 ignored issues
show
Bug introduced by
The type Doctrine\DBAL\Types\Types was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Doctrine\Migrations\AbstractMigration;
0 ignored issues
show
Bug introduced by
The type Doctrine\Migrations\AbstractMigration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
final class Version20210411114720 extends AbstractMigration
13
{
14
    private const PLAYER_TABLE = 'player';
15
    private const HISTORY_TABLE = 'history';
16
17
    public function getDescription(): string
18
    {
19
        return 'Create tables.';
20
    }
21
22
    public function up(Schema $schema): void
23
    {
24
        $this->createPlayerTable($schema);
25
        $this->createHistoryTable($schema);
26
    }
27
28
    public function down(Schema $schema): void
29
    {
30
        $schema->dropTable(self::PLAYER_TABLE);
31
        $schema->dropTable(self::HISTORY_TABLE);
32
    }
33
34
    private function createPlayerTable(Schema $schema): void
35
    {
36
        $table = $schema->createTable(self::PLAYER_TABLE);
37
        $table->addColumn('id', Types::GUID)->setUnsigned(true)->setAutoincrement(true);
38
        $table->addColumn('nickname', Types::STRING);
39
        $table->addColumn('password', Types::STRING);
40
        $table->addColumn('level', Types::SMALLINT);
41
        $table->addColumn('role', Types::STRING);
42
43
        $this->createAndUpdateDate($table);
44
45
        $table->setPrimaryKey(['id']);
46
        $table->addUniqueIndex(['nickname']);
47
    }
48
49
    private function createHistoryTable(Schema $schema): void
50
    {
51
        $table = $schema->createTable(self::HISTORY_TABLE);
52
        $table->addColumn('id', Types::GUID)->setUnsigned(true)->setAutoincrement(true);
53
        $table->addColumn('player', Types::GUID);
54
        $table->addColumn('level', Types::GUID);
55
56
        $this->createAndUpdateDate($table);
57
58
        $table->setPrimaryKey(['id']);
59
        $table->addForeignKeyConstraint(self::PLAYER_TABLE, ['player'], ['id']);
60
    }
61
62
    private function createAndUpdateDate(Table $table): void
63
    {
64
        $table->addColumn('createdAt', Types::DATETIME_IMMUTABLE)->setNotnull(true);
65
        $table->addColumn('updatedAt', Types::DATETIME_IMMUTABLE)->setNotnull(true);
66
    }
67
}
68