Completed
Push — master ( eb7aa9...68c092 )
by zacksleo
02:38 queued 01:19
created

UserRedisBehavior::events()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 2
cts 2
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
namespace zacksleo\yii2\oauth2\common\behaviors;
4
5
use zacksleo\yii2\oauth2\common\helpers\Predis;
6
use yii\base\Behavior;
7
use yii\db\ActiveRecord;
8
9
class UserRedisBehavior extends Behavior
10
{
11 2
    public function events()
12
    {
13
        return [
14 2
            ActiveRecord::EVENT_AFTER_DELETE => 'afterDelete',
15
        ];
16
    }
17
18 1
    public function afterDelete($event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
    {
20
        /* @var $user \common\models\User */
21 1
        $user = $this->owner;
22 1
        if (!empty($user)) {
23
            //删除缓存
24 1
            Predis::getInstance()->getClient()->deleteUserToken($user->id);
25
        }
26 1
    }
27
}
28