Conditions | 7 |
Paths | 16 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 0 |
1 | <?php |
||
43 | public function run() |
||
44 | { |
||
45 | $value = $this->model->{$this->attribute}; |
||
46 | $color = $value === 0 ? 'primary' : 'success'; |
||
47 | |||
48 | if ($value < 0) { |
||
49 | $color = 'warning'; |
||
50 | } |
||
51 | |||
52 | if ($this->compare && $value < -($this->model->{$this->compare} ?: 0)) { |
||
53 | $color = 'danger'; |
||
54 | } |
||
55 | |||
56 | $url = $this->url; |
||
57 | $txt = Yii::$app->formatter->format($value, ['currency', $this->model->currency]); |
||
58 | $ops = ['class' => 'text-nowrap text-' . $this->getColor($color), 'data-pjax' => 0]; |
||
59 | |||
60 | return $url ? Html::a($txt, $url, $ops) : Html::tag('span', $txt, $ops); |
||
61 | } |
||
62 | } |
||
63 |