Passed
Push — master ( a90c1b...36c150 )
by Razon
02:16
created

CreatorBehavior   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 6
c 1
b 0
f 0
dl 0
loc 11
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 7 1
1
<?php
2
namespace App\Behavior;
3
4
use Yii;
5
use yii\behaviors\AttributesBehavior;
6
use yii\db\ActiveRecord;
7
8
class CreatorBehavior extends AttributesBehavior
9
{
10
    public $creatorAttribute = 'creator';
11
12
    public function init()
13
    {
14
        parent::init();
15
16
        $this->attributes = [
17
            $this->creatorAttribute => [
18
                ActiveRecord::EVENT_BEFORE_INSERT => Yii::$app->getUser()->getId(),
19
            ],
20
        ];
21
    }
22
}
23