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

PriceDifferenceWidget   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 20
ccs 0
cts 12
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 13 4
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