Passed
Pull Request — master (#5)
by aguevaraIL
03:57
created

Credit::tableName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace app\models;
4
5
use Yii;
6
use roaresearch\yii2\workflow\models\Workflow;
7
8
/**
9
 * This is the model class for table `{{%credit}}`.
10
 *
11
 * @property integer $id
12
 * @property string $credit
13
 */
14
class Credit extends \roaresearch\yii2\workflow\models\Process
15
{
16
    /**
17
     * @inheritdoc
18
     */
19
    public static function tableName()
20
    {
21
        return '{{%credit}}';
22
    }
23
24
    protected function assignmentClass(): string
25
    {
26
        return CreditAssignment::class;
27
    }
28
29
    protected function workLogClass(): string
30
    {
31
        return CreditWorkLog::class;
32
    }
33
34
    public function getWorkflowId(): int
35
    {
36
        return $this->workflow_id;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->workflow_id could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
Bug Best Practice introduced by
The property workflow_id does not exist on app\models\Credit. Since you implemented __get, consider adding a @property annotation.
Loading history...
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function rules()
43
    {
44
        return array_merge(parent::rules(), [
45
            [['workflow_id'], 'required'],
46
            [
47
                ['workflow_id'],
48
                'exist',
49
                'skipOnError' => true,
50
                'targetClass' => Workflow::class,
51
                'targetAttribute' => ['workflow_id' => 'id'],
52
            ],
53
        ]);
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function attributeLabels()
60
    {
61
        return [
62
            'id' => Yii::t('app', 'ID'),
63
            'workflow_id' => Yii::t('app', 'Workflow ID'),
64
        ];
65
    }
66
}
67