Completed
Pull Request — master (#381)
by
unknown
05:42
created

SchemaConfigurator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B configure() 0 59 1
1
<?php
2
/**
3
 * @file
4
 */
5
6
namespace CultuurNet\UDB3\ReadModel\Index\Doctrine;
7
8
use CultuurNet\UDB3\Doctrine\DBAL\SchemaConfiguratorInterface;
9
use Doctrine\DBAL\Schema\AbstractSchemaManager;
10
use ValueObjects\StringLiteral\StringLiteral;
11
12
class SchemaConfigurator implements SchemaConfiguratorInterface
13
{
14
    /**
15
     * @var StringLiteral
16
     */
17
    protected $tableName;
18
19
    /**
20
     * @param StringLiteral $tableName
21
     */
22
    public function __construct(StringLiteral $tableName)
23
    {
24
        $this->tableName = $tableName;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function configure(AbstractSchemaManager $schemaManager)
31
    {
32
        $schema = $schemaManager->createSchema();
33
        $table = $schema->createTable($this->tableName->toNative());
34
35
        $table->addColumn(
36
            'entity_id',
37
            'guid',
38
            array('length' => 36, 'notnull' => true)
39
        );
40
        $table->addColumn(
41
            'entity_type',
42
            'string',
43
            array('length' => 36, 'notnull' => true)
44
        );
45
        $table->addColumn(
46
            'title',
47
            'text'
48
        );
49
        $table->addColumn(
50
            'uid',
51
            'guid',
52
            array('length' => 36, 'notnull' => true)
53
        );
54
        $table->addColumn(
55
            'zip',
56
            'string',
57
            array('length' => 32)
58
        );
59
        $table->addColumn(
60
            'country',
61
            'string',
62
            array('length' => 2)
63
        );
64
        $table->addColumn(
65
            'created',
66
            'string',
67
            array('length' => 32, 'notnull' => true)
68
        );
69
        $table->addColumn(
70
            'updated',
71
            'string',
72
            array('length' => 32, 'notnull' => true)
73
        );
74
        $table->addColumn(
75
            'owning_domain',
76
            'string',
77
            array('length' => 256, 'notnull' => true)
78
        );
79
        $table->addColumn(
80
            'entity_iri',
81
            'string',
82
            array('length' => 256)
83
        );
84
85
        $table->setPrimaryKey(['entity_id']);
86
87
        $schemaManager->createTable($table);
88
    }
89
}
90