Completed
Push — master ( 958dbc...2d3a59 )
by Dmitry
05:33
created

PricePresenter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderPrice() 0 5 1
1
<?php
2
3
namespace hipanel\modules\finance\grid\presenters\price;
4
5
use hipanel\modules\finance\models\Price;
6
use Yii;
7
8
/**
9
 * Class PricePresenter contains methods that present price properties.
10
 * You can override this class to add custom presentations support.
11
 *
12
 * @author Dmytro Naumenko <[email protected]>
13
 */
14
class PricePresenter
15
{
16
    /**
17
     * @param Price $price
18
     * @return string
19
     * @throws \yii\base\InvalidConfigException
20
     */
21
    public function renderPrice($price): string
22
    {
23
        return Yii::$app->formatter->asCurrency($price->price, $price->currency)
24
            . '/' . Yii::t('hipanel.finance.price', $price->getUnitOptions()[$price->unit]);
25
    }
26
}
27