Completed
Pull Request — master (#53)
by Klochok
04:58 queued 02:41
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 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