Completed
Pull Request — master (#53)
by Klochok
03:52
created

PincodePrompt   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 3
dl 0
loc 29
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A run() 0 6 1
A isPINFailed() 0 4 2
1
<?php
2
/**
3
 * HiPanel core package.
4
 *
5
 * @link      https://hipanel.com/
6
 * @package   hipanel-core
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2014-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\widgets;
12
13
use hipanel\assets\PincodePromptAsset;
14
use hipanel\modules\client\helpers\HasPINCode;
15
use Yii;
16
use yii\base\Widget;
17
18
class PincodePrompt extends Widget
19
{
20
    public $loadingText;
21
    /**
22
     * @var bool
23
     */
24
    private $hasPINCode;
25
26
    public function __construct(HasPINCode $hasPINCode, $config = [])
27
    {
28
        parent::__construct($config);
29
        $this->hasPINCode = $hasPINCode;
0 ignored issues
show
Documentation Bug introduced by
It seems like $hasPINCode of type object<hipanel\modules\client\helpers\HasPINCode> is incompatible with the declared type boolean of property $hasPINCode.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
30
    }
31
32
    public function run()
33
    {
34
        PincodePromptAsset::register($this->view);
35
36
        return $this->render('pincode-prompt');
37
    }
38
39
    /**
40
     * @return bool
41
     */
42
    public function isPINFailed(): bool
43
    {
44
        return !$this->hasPINCode->__invoke() && Yii::$app->user->can('manage');
0 ignored issues
show
Bug introduced by
The method __invoke cannot be called on $this->hasPINCode (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...
45
    }
46
}
47