OutboxEndpointSchemaProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 38
ccs 0
cts 16
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getSchemaFor() 0 25 2
1
<?php
2
namespace PSB\Persistence\Doctrine1\Outbox\SchemaProvider;
3
4
5
use PSB\Persistence\Doctrine1\Schema;
6
use PSB\Persistence\Doctrine1\SchemaProviderInterface;
7
8
class OutboxEndpointSchemaProvider implements SchemaProviderInterface
9
{
10
    /**
11
     * @var Schema[]
12
     */
13
    private $schemas = [];
14
15
    /**
16
     * @param string $tableName
17
     *
18
     * @return Schema
19
     */
20
    public function getSchemaFor($tableName)
21
    {
22
        if (!isset($this->schemas[$tableName])) {
23
            $this->schemas[$tableName] = new Schema(
24
                $tableName,
25
                [
26
                    'id' => ['type' => 'integer', 'primary' => true, 'autoincrement' => true],
27
                    'lookup_hash' => ['type' => 'string', 'length' => 32, 'fixed' => 1, 'notnull' => true],
28
                    'name' => ['type' => 'string', 'notnull' => true]
29
                ],
30
                [
31
                    'indexes' => [
32
                        'lookup_hash' => [
33
                            'fields' => [
34
                                'lookup_hash' => []
35
                            ],
36
                            'type' => 'unique'
37
                        ]
38
                    ]
39
                ]
40
            );
41
        }
42
43
        return $this->schemas[$tableName];
44
    }
45
}
46