Completed
Push — master ( b864d9...3fa98b )
by Dmitry
07:42 queued 03:17
created

DefaultQuantityFormatter::getClientValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace hipanel\modules\finance\logic\bill;
4
5
use hipanel\base\Model;
6
use hipanel\modules\finance\models\Bill;
7
use hipanel\modules\finance\models\Charge;
8
use hiqdev\php\units\Quantity;
9
use hiqdev\php\units\yii2\formatters\IntlFormatter;
10
11
/**
12
 * Class DefaultQuantityFormatter
13
 *
14
 * @author Dmytro Naumenko <[email protected]>
15
 */
16
class DefaultQuantityFormatter implements QuantityFormatterInterface
17
{
18
    /**
19
     * @var Quantity
20
     */
21
    protected $quantity;
22
23
    /**
24
     * @var IntlFormatter
25
     */
26
    protected $intlFormatter;
27
28
    /**
29
     * MonthlyQuantity constructor.
30
     *
31
     * @param Quantity $quantity
32
     * @param IntlFormatter $intlFormatter
33
     */
34
    public function __construct(Quantity $quantity, IntlFormatter $intlFormatter)
35
    {
36
        $this->quantity = $quantity;
37
        $this->intlFormatter = $intlFormatter;
38
    }
39
40
    public function format(): string
41
    {
42
        return $this->intlFormatter->format($this->quantity);
43
    }
44
45
    public function getValue(): string
46
    {
47
        return $this->quantity->getQuantity();
48
    }
49
50
    public function getClientValue(): string
51
    {
52
        return $this->getValue();
53
    }
54
55
    protected function getQuantity(): Quantity
56
    {
57
        return $this->quantity;
58
    }
59
}
60