DefaultQuantityFormatter::getQuantity()   A
last analyzed

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
 * 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\logic\bill;
12
13
use hiqdev\php\units\Quantity;
14
use hiqdev\php\units\yii2\formatters\IntlFormatter;
15
16
/**
17
 * Class DefaultQuantityFormatter.
18
 *
19
 * @author Dmytro Naumenko <[email protected]>
20
 */
21
class DefaultQuantityFormatter implements QuantityFormatterInterface
22
{
23
    /**
24
     * @var Quantity
25
     */
26
    protected $quantity;
27
28
    /**
29
     * @var IntlFormatter
30
     */
31
    protected $intlFormatter;
32
33
    /**
34
     * MonthlyQuantity constructor.
35
     *
36
     * @param Quantity $quantity
37
     * @param IntlFormatter $intlFormatter
38
     */
39
    public function __construct(Quantity $quantity, IntlFormatter $intlFormatter)
40
    {
41
        $this->quantity = $quantity;
42
        $this->intlFormatter = $intlFormatter;
43
    }
44
45
    public function format(): string
46
    {
47
        return $this->intlFormatter->format($this->quantity);
48
    }
49
50
    public function getValue(): string
51
    {
52
        return $this->quantity->getQuantity();
53
    }
54
55
    public function getClientValue(): string
56
    {
57
        return $this->getValue();
58
    }
59
60
    protected function getQuantity(): Quantity
61
    {
62
        return $this->quantity;
63
    }
64
}
65