Completed
Pull Request — master (#117)
by Kristof
04:39
created

SchemaConfigurator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 4
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * @file
4
 */
5
6
namespace CultuurNet\UDB3\Place\ReadModel\Permission\Doctrine;
7
8
use CultuurNet\UDB3\Doctrine\DBAL\SchemaConfiguratorInterface;
9
use Doctrine\DBAL\Schema\AbstractSchemaManager;
10
use ValueObjects\String\String as StringLiteral;
11
12 View Code Duplication
class SchemaConfigurator implements SchemaConfiguratorInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
            'place_id',
37
            'guid',
38
            array('length' => 36, 'notnull' => true)
39
        );
40
        $table->addColumn(
41
            'user_id',
42
            'guid',
43
            array('length' => 36, 'notnull' => true)
44
        );
45
46
        $table->setPrimaryKey(['place_id', 'user_id']);
47
48
        $schemaManager->createTable($table);
49
    }
50
}
51