Completed
Push — master ( 4d6fa7...83de61 )
by
unknown
13:33
created

CertificatePricePresenter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 27
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Finance module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-finance
6
 * @package   hipanel-module-finance
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\finance\grid\presenters\price;
12
13
use hipanel\modules\finance\models\Price;
14
use Money\MoneyFormatter;
15
use yii\i18n\Formatter;
16
use yii\web\User;
17
18
/**
19
 * Class CertificatePricePresenter.
20
 *
21
 * @author Dmytro Naumenko <[email protected]>
22
 */
23
class CertificatePricePresenter extends PricePresenter
24
{
25
    protected MoneyFormatter $moneyFormatter;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
26
27
    public function __construct(Formatter $formatter, User $user, MoneyFormatter $moneyFormatter)
28
    {
29
        parent::__construct($formatter, $user);
30
31
        $this->moneyFormatter = $moneyFormatter;
32
    }
33
34
    /**
35
     * @param \hipanel\modules\finance\models\CertificatePrice $price
36
     * @return string
37
     */
38
    public function renderPrice(Price $price): string
39
    {
40
        $result = [];
41
        foreach ($price->sums as $period => $amount) {
42
            $result[] = $this->moneyFormatter->format($amount);
43
        }
44
45
        return implode('&nbsp;/&nbsp;', $result);
46
    }
47
}
48