Completed
Pull Request — master (#53)
by Klochok
04:58 queued 02:41
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 HasPINCode
23
     */
24
    private $hasPINCode;
25
26
    public function __construct(HasPINCode $hasPINCode, $config = [])
27
    {
28
        parent::__construct($config);
29
        $this->hasPINCode = $hasPINCode;
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');
45
    }
46
}
47