Completed
Push — master ( 030ae6...89eb04 )
by Dmitry
04:29
created

PriceDifferenceWidget::run()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
ccs 0
cts 12
cp 0
rs 9.2
cc 4
eloc 8
nc 2
nop 0
crap 20
1
<?php
2
3
namespace hipanel\modules\finance\widgets;
4
5
use Yii;
6
use yii\base\Widget;
7
use yii\helpers\Html;
8
9
class PriceDifferenceWidget extends Widget
10
{
11
    public $old;
12
13
    public $new;
14
15
    public function run()
16
    {
17
        $diff = $this->new - $this->old;
18
        if ($diff != 0) {
19
            print Html::tag(
20
                'span',
21
                ($diff > 0 ? '+' : '') . Yii::$app->formatter->asDecimal($diff, 2),
22
                ['class' => $diff > 0 ? 'text-success' : 'text-danger']
23
            );
24
        }
25
26
        return;
27
    }
28
}
29