LastVisitBehavior::afterAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 9
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace modules\users\behavior;
4
5
use Yii;
6
use yii\base\Behavior;
7
use yii\console\Controller;
8
9
/**
10
 * Class LastVisitBehavior
11
 * @package modules\users\behavior
12
 */
13
class LastVisitBehavior extends Behavior
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function events()
19
    {
20
        return [
21
            Controller::EVENT_AFTER_ACTION => 'afterAction'
22
        ];
23
    }
24
25
    /**
26
     * @return bool
27
     */
28
    public function afterAction()
29
    {
30
        if (!Yii::$app->user->isGuest) {
31
            /** @var \yii\web\IdentityInterface $model */
32
            $model = Yii::$app->user->identity;
33
            /** @var \yii\behaviors\TimestampBehavior $model Updates a timestamp attribute to the current timestamp. */
34
            $model->touch('last_visit');
35
        }
36
        return true;
37
    }
38
}
39