OutboxMessageSchemaProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
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 48
ccs 0
cts 24
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getSchemaFor() 0 35 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 OutboxMessageSchemaProvider 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
                    'endpoint_id' => ['type' => 'integer', 'notnull' => true],
28
                    'message_id' => ['type' => 'string', 'length' => 32, 'fixed' => 1, 'notnull' => true],
29
                    'is_dispatched' => ['type' => 'boolean', 'notnull' => true],
30
                    'dispatched_at' => ['type' => 'timestamp'],
31
                    'transport_operations' => ['type' => 'clob', 'notnull' => true]
32
                ],
33
                [
34
                    'indexes' => [
35
                        'me' => [
36
                            'fields' => [
37
                                'message_id' => [],
38
                                'endpoint_id' => []
39
                            ],
40
                            'type' => 'unique'
41
                        ],
42
                        'di' => [
43
                            'fields' => [
44
                                'dispatched_at' => [],
45
                                'is_dispatched' => []
46
                            ]
47
                        ]
48
                    ]
49
                ]
50
            );
51
        }
52
53
        return $this->schemas[$tableName];
54
    }
55
}
56