Completed
Pull Request — master (#384)
by Kristof
04:13 queued 34s
created

SchemaConfigurator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 51
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 32 1
1
<?php
2
3
namespace CultuurNet\UDB3\MyOrganizers\ReadModel\Doctrine;
4
5
use CultuurNet\UDB3\Doctrine\DBAL\SchemaConfiguratorInterface;
6
use Doctrine\DBAL\Schema\AbstractSchemaManager;
7
use ValueObjects\StringLiteral\StringLiteral;
8
9
class SchemaConfigurator implements SchemaConfiguratorInterface
10
{
11
    /**
12
     * @var StringLiteral
13
     */
14
    protected $tableName;
15
16
    /**
17
     * @param StringLiteral $tableName
18
     */
19
    public function __construct(StringLiteral $tableName)
20
    {
21
        $this->tableName = $tableName;
22
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function configure(AbstractSchemaManager $schemaManager)
28
    {
29
        $schema = $schemaManager->createSchema();
30
        $table = $schema->createTable($this->tableName->toNative());
31
32
        $table->addColumn(
33
            'id',
34
            'guid',
35
            array('length' => 36, 'notnull' => true)
36
        );
37
        $table->addColumn(
38
            'uid',
39
            'guid',
40
            array('length' => 36, 'notnull' => true)
41
        );
42
        $table->addColumn(
43
            'created',
44
            'string',
45
            array('length' => 32, 'notnull' => true)
46
        );
47
        $table->addColumn(
48
            'updated',
49
            'string',
50
            array('length' => 32, 'notnull' => true)
51
        );
52
53
        $table->setPrimaryKey(['id']);
54
55
        $table->addIndex(['uid']);
56
57
        $schemaManager->createTable($table);
58
    }
59
}
60