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

SchemaConfigurator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A configure() 20 20 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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