VNCFormatter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 23
c 0
b 0
f 0
ccs 0
cts 14
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 3 1
A run() 0 11 1
1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\server\widgets;
12
13
use Yii;
14
use yii\base\Widget;
15
use yii\db\ActiveRecord;
16
use yii\helpers\Html;
17
use yii\web\View;
18
19
class VNCFormatter extends Widget
20
{
21
    /**
22
     * @var ActiveRecord
23
     */
24
    public $model;
25
26
    public function init()
27
    {
28
        parent::init();
29
    }
30
31
    public function run()
32
    {
33
        $this->getView()->registerJs("$('.discount-popover').popover();", View::POS_READY, 'discount-popover');
34
35
        return Html::tag($this->tagName,
0 ignored issues
show
Bug Best Practice introduced by
The property tagName does not exist on hipanel\modules\server\widgets\VNCFormatter. Since you implemented __get, consider adding a @property annotation.
Loading history...
36
            Yii::$app->formatter->asPercent($this->current / 100),
0 ignored issues
show
Bug Best Practice introduced by
The property current does not exist on hipanel\modules\server\widgets\VNCFormatter. Since you implemented __get, consider adding a @property annotation.
Loading history...
37
            [
38
                'title'        => Yii::t('hipanel:server', 'Next discount'),
39
                'class'        => 'btn btn-default btn-xs discount-popover',
40
                'data-trigger' => 'focus',
41
                'data-content' => Yii::$app->formatter->asPercent($this->next / 100),
0 ignored issues
show
Bug Best Practice introduced by
The property next does not exist on hipanel\modules\server\widgets\VNCFormatter. Since you implemented __get, consider adding a @property annotation.
Loading history...
42
            ]);
43
    }
44
}
45