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

SchemaConfigurator::configure()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 59

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 59
rs 8.8945
c 0
b 0
f 0
cc 1
nc 1
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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