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

PricePresenter::renderPrice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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