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

PincodePrompt::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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