Transition   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 45
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A slugBehaviorConfig() 0 6 1
A extraFields() 0 3 1
A getLinks() 0 5 1
1
<?php
2
3
namespace roaresearch\yii2\workflow\roa\models;
4
5
use roaresearch\yii2\roa\hal\{Contract, ContractTrait};
6
use roaresearch\yii2\workflow\models as base;
7
8
/**
9
 * ROA contract to handle workflow transitions records.
10
 */
11
class Transition extends base\Transition implements Contract
12
{
13
    use ContractTrait {
14
        getLinks as getContractLinks;
15
    }
16
17
    /**
18
     * @inheritdoc
19
     */
20
    protected $stageClass = Stage::class;
21
22
    /**
23
     * @inheritdoc
24
     */
25
    protected $permissionClass = TransitionPermission::class;
26
27
    /**
28
     * @inheritdoc
29
     */
30 10
    protected function slugBehaviorConfig(): array
31
    {
32
        return [
33 10
            'resourceName' => 'transition',
34
            'parentSlugRelation' => 'sourceStage',
35
            'idAttribute' => 'target_stage_id',
36
        ];
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42 6
    public function getLinks()
43
    {
44 6
        return array_merge($this->getContractLinks(), [
45 6
            'permissions' => $this->getSelfLink() . '/permission',
46 6
            'target_stage' => $this->targetStage->getSelfLink(),
0 ignored issues
show
Bug introduced by
The method getSelfLink() does not exist on roaresearch\yii2\workflow\models\Stage. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
            'target_stage' => $this->targetStage->/** @scrutinizer ignore-call */ getSelfLink(),
Loading history...
47
        ]);
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53 6
    public function extraFields()
54
    {
55 6
        return ['sourceStage', 'targetStage', 'permissions'];
56
    }
57
}
58