Conditions | 4 |
Paths | 6 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public function renderPrice($price): string |
||
21 | { |
||
22 | $formatter = Yii::$app->formatter; |
||
23 | |||
24 | $unit = ''; |
||
25 | if ($price->getUnitLabel()) { |
||
26 | $unit = ' ' . Yii::t('hipanel:finance', 'per {unit}', ['unit' => $price->getUnitLabel()]); |
||
27 | } |
||
28 | |||
29 | $result = [ |
||
30 | Html::tag('strong', $formatter->asCurrency($price->price, $price->currency) . $unit) |
||
31 | ]; |
||
32 | foreach ($price->subprices as $currencyCode => $amount) { |
||
33 | try { |
||
34 | $result[] = $formatter->asCurrency($amount, $currencyCode); |
||
35 | } catch (InvalidConfigException $e) { |
||
36 | $result[] = $amount . ' ' . $currencyCode; |
||
37 | } |
||
38 | } |
||
39 | |||
40 | |||
41 | return implode(' — ', $result); |
||
42 | } |
||
43 | } |
||
44 |