Assignment   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 10 3
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
namespace rhosocial\user\rbac;
14
15
use rhosocial\user\User;
16
17
/**
18
 * @version 1.0
19
 * @author vistart <[email protected]>
20
 */
21
class Assignment extends \yii\rbac\Assignment
22
{
23
    /**
24
     * @var string|User user ID (see [[\rhosocial\user\User::guid]])
25
     */
26
    public $userGuid;
27
    
28
    /**
29
     * @var string the time of invalidation of this Assignment. (Format: Y-m-d H:i:s)
30
     */
31
    public $failedAt;
32
    
33
    public function init()
34
    {
35
        if ($this->failedAt !== null && strtotime($this->failedAt) < strtotime(date('Y-m-d H:i:s'))) {
36
            return \Yii::$app->db->createCommand()
37
                ->delete(\Yii::$app->authManager->assignmentTable, [
38
                    'user_guid' => (string) $this->userGuid,
39
                    'item_name' => $this->roleName
40
                ])->execute() > 0;
41
        }
42
    }
43
}
44