Passed
Push — master ( aaaa1a...18a970 )
by vistart
08:31
created

User::getGuid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
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\base\models\web;
14
15
use rhosocial\base\models\models\BaseUserModel;
16
17
/**
18
 * @version 1.0
19
 * @author vistart <[email protected]>
20
 */
21
class User extends \yii\web\User
22
{
23
    private $_access = [];
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
24
    
25
    public function getGuid()
26
    {
27
        $identity = $this->getIdentity();
28
        /* @var $identity BaseUserModel */
29
        return $identity !== null ? $identity->getGUID() : null;
30
    }
31
    
32
    public function can($permissionName, $params = [], $allowCaching = true)
33
    {
34
        if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) {
35
            return $this->_access[$permissionName];
36
        }
37
        if (($accessChecker = $this->getAccessChecker()) === null) {
38
            return false;
39
        }
40
        $access = $accessChecker->checkAccess($this->getGuid(), $permissionName, $params);
41
        if ($allowCaching && empty($params)) {
42
            $this->_access[$permissionName] = $access;
43
        }
44
45
        return $access;
46
    }
47
}