Passed
Push — master ( 4a9186...cf0fc9 )
by vistart
03:05
created

Assignment   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 8 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 14
    public function init()
34
    {
35 14
        if ($this->failedAt !== null && strtotime($this->failedAt) < strtotime(date('Y-m-d H:i:s'))) {
36 2
            return \Yii::$app->db->createCommand()
37 2
                ->delete(\Yii::$app->authManager->assignmentTable, ['user_guid' => (string) $this->userGuid, 'item_name' => $this->roleName])
38 2
                ->execute() > 0;
39
        }
40
    }
41
}