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

OauthClientsDeleteBehavior   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

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

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\helpers\Predis;
6
use zacksleo\yii2\oauth2\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 7
    public function events()
15
    {
16
        return [
17 7
            ActiveRecord::EVENT_AFTER_DELETE => 'afterDelete'
18
        ];
19
    }
20
21 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...
22
    {
23
        /* @var $model OauthClients */
24 1
        $model = $this->owner;
25
        //删除缓存
26 1
        Predis::getInstance()->getClient()->deleteClientToken($model->client_id);
27
        //删除Token
28
        //OauthAccessTokens::deleteAll(['client_id' => $model->client_id]);
29
        //删除授权码
30 1
        OauthAuthorizationCodes::deleteAll(['client_id' => $model->client_id]);
31
        //删除刷新Token
32 1
        OauthRefreshTokens::deleteAll(['client_id' => $model->client_id]);
33 1
    }
34
}
35