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

UserRedisBehavior   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 19
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A events() 0 6 1
A afterDelete() 0 9 2
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