Completed
Push — master ( d69358...27ffc6 )
by Dmitry
04:53 queued 53s
created

User   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
ccs 0
cts 16
cp 0
rs 10
wmc 4
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A not() 0 9 2
A is() 0 9 2
1
<?php
2
3
/*
4
 * HiPanel core package
5
 *
6
 * @link      https://hipanel.com/
7
 * @package   hipanel-core
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hipanel\components;
13
14
use yii\base\InvalidConfigException;
15
16
class User extends \yii\web\User
17
{
18
    /**
19
     * @var string the seller login
20
     */
21
    public $seller;
22
23
    public function not($key)
24
    {
25
        $identity = $this->getIdentity();
26
        if (!$identity) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $identity of type null|boolean is loosely compared to false; this is ambiguous if the boolean can be false. You might want to explicitly use !== null instead.

If an expression can have both false, and null as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.

$a = canBeFalseAndNull();

// Instead of
if ( ! $a) { }

// Better use one of the explicit versions:
if ($a !== null) { }
if ($a !== false) { }
if ($a !== null && $a !== false) { }
Loading history...
27
            throw new InvalidConfigException();
28
        }
29
30
        return $identity->not($key);
0 ignored issues
show
Bug introduced by
The method not cannot be called on $identity (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
31
    }
32
33
    public function is($key)
34
    {
35
        $identity = $this->getIdentity();
36
        if (!$identity) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $identity of type null|boolean is loosely compared to false; this is ambiguous if the boolean can be false. You might want to explicitly use !== null instead.

If an expression can have both false, and null as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.

$a = canBeFalseAndNull();

// Instead of
if ( ! $a) { }

// Better use one of the explicit versions:
if ($a !== null) { }
if ($a !== false) { }
if ($a !== null && $a !== false) { }
Loading history...
37
            throw new InvalidConfigException();
38
        }
39
40
        return $identity->is($key);
0 ignored issues
show
Bug introduced by
The method is cannot be called on $identity (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
41
    }
42
}
43