OutboxEndpointSchemaProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 27
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSchemaFor() 0 14 2
1
<?php
2
namespace PSB\Persistence\Doctrine2\Outbox\SchemaProvider;
3
4
5
use Doctrine\DBAL\Schema\Schema;
6
use PSB\Persistence\Doctrine2\SchemaProviderInterface;
7
8
class OutboxEndpointSchemaProvider implements SchemaProviderInterface
9
{
10
    /**
11
     * @var Schema[]
12
     */
13
    private $schemas = [];
14
15
    /**
16
     * @param string $tableName
17
     *
18
     * @return Schema
19
     */
20
    public function getSchemaFor($tableName)
21
    {
22
        if (!isset($this->schemas[$tableName])) {
23
            $this->schemas[$tableName] = new Schema();
24
            $table = $this->schemas[$tableName]->createTable($tableName);
25
            $table->addColumn('id', 'integer', ['autoincrement' => true]);
26
            $table->addColumn('lookup_hash', 'binary', ['length' => 16, 'fixed' => true]);
27
            $table->addColumn('name', 'text');
28
            $table->setPrimaryKey(['id']);
29
            $table->addUniqueIndex(['lookup_hash']);
30
        }
31
32
        return $this->schemas[$tableName];
33
    }
34
}
35