WorkLog   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A foreignKeys() 0 5 1
A columns() 0 7 1
A getTableName() 0 3 1
1
<?php
2
3
namespace roaresearch\yii2\workflow\migrations;
4
5
/**
6
 * Base Migration for creating worklog tables for process.
7
 */
8
abstract class WorkLog extends \roaresearch\yii2\rmdb\migrations\CreatePivot
9
{
10
    /**
11
     * @var string suffix attached at the end of the process table.
12
     */
13
    public $worklogSuffix = '_worklog';
14
15
    /**
16
     * @return string name of the table to which the worklog will be attached.
17
     */
18
    abstract public function getProcessTableName(): string;
19
20
    /**
21
     * @inhertidoc
22
     */
23
    public function getTableName(): string
24
    {
25
        return $this->getProcessTableName() . $this->worklogSuffix;
26
    }
27
28
    /**
29
     * @inhertidoc
30
     */
31
    public function columns(): array
32
    {
33
        return [
34
            'id' => $this->primaryKey(),
35
            'process_id' => $this->normalKey(),
36
            'stage_id' => $this->normalKey(),
37
            'comment' => $this->text(),
38
        ];
39
    }
40
41
    /**
42
     * @inhertidoc
43
     */
44
    public function foreignKeys(): array
45
    {
46
        return [
47
            'stage_id' => 'workflow_stage',
48
            'process_id' => $this->getProcessTableName(),
49
        ];
50
    }
51
}
52