Assignment   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A columns() 0 5 1
A getTableName() 0 3 1
A foreignKeys() 0 4 1
A compositePrimaryKeys() 0 3 1
1
<?php
2
3
namespace roaresearch\yii2\workflow\migrations;
4
5
/**
6
 * Base Migration for creating assignment tables for process.
7
 */
8
abstract class Assignment extends \roaresearch\yii2\rmdb\migrations\CreatePivot
9
{
10
    /**
11
     * @var string suffix attached at the end of the process table.
12
     */
13
    public $assignmentSuffix = '_assignment';
14
15
    /**
16
     * @return string name of the table to which the assignment 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->assignmentSuffix;
26
    }
27
28
    /**
29
     * @inhertidoc
30
     */
31
    public function columns(): array
32
    {
33
        return [
34
            'process_id' => $this->normalKey(),
35
            'user_id' => $this->normalKey(),
36
        ];
37
    }
38
39
    /**
40
     * @inhertidoc
41
     */
42
    public function foreignKeys(): array
43
    {
44
        return [
45
           'process_id' => $this->getProcessTableName(),
46
        ];
47
    }
48
 
49
    /**
50
     * @inhertidoc
51
     */
52
    public function compositePrimaryKeys(): array
53
    {
54
        return ['process_id', 'user_id'];
55
    }
56
}
57