Completed
Push — master ( b5be07...eb7aa9 )
by zacksleo
01:54
created

OauthClientsDeleteBehavior   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 25%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 23
ccs 2
cts 8
cp 0.25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A events() 0 6 1
A afterDelete() 0 13 1
1
<?php
2
3
namespace zacksleo\yii2\oauth2\common\behaviors;
4
5
use zacksleo\yii2\oauth2\common\predis\Predis;
6
use common\models\OauthClients;
7
use filsh\yii2\oauth2server\models\OauthAuthorizationCodes;
8
use filsh\yii2\oauth2server\models\OauthRefreshTokens;
9
use yii\base\Behavior;
10
use yii\db\ActiveRecord;
11
12
class OauthClientsDeleteBehavior extends Behavior
13
{
14 4
    public function events()
15
    {
16
        return [
17 4
            ActiveRecord::EVENT_AFTER_DELETE => 'afterDelete'
18
        ];
19
    }
20
21
    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...
22
    {
23
        /* @var $model OauthClients */
24
        $model = $this->owner;
25
        //删除缓存
26
        Predis::getInstance()->getClient()->deleteClientToken($model->client_id);
27
        //删除Token
28
        //OauthAccessTokens::deleteAll(['client_id' => $model->client_id]);
29
        //删除授权码
30
        OauthAuthorizationCodes::deleteAll(['client_id' => $model->client_id]);
31
        //删除刷新Token
32
        OauthRefreshTokens::deleteAll(['client_id' => $model->client_id]);
33
    }
34
}
35