Completed
Push — master ( db5ad0...ac6025 )
by Andy
06:43
created

MoneyNormalizer::setMoneyFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Palmtree\Csv\Normalizer;
4
5
class MoneyNormalizer extends AbstractNormalizer
6
{
7
    protected $moneyFormat;
8
9
    /**
10
     * MoneyNormalizer constructor.
11
     *
12
     * @param null|NormalizerInterface $normalizer
13
     * @param string                   $format
14
     */
15
    public function __construct($normalizer = null, $format = '%.2n')
16
    {
17
        parent::__construct($normalizer);
18
19
        $this->setMoneyFormat($format);
20
    }
21
22
    /**
23
     * @param string $moneyFormat
24
     *
25
     * @return MoneyNormalizer
26
     */
27
    public function setMoneyFormat($moneyFormat)
28
    {
29
        $this->moneyFormat = $moneyFormat;
30
31
        return $this;
32
    }
33
34
    /**
35
     * @return mixed
36
     */
37
    public function getMoneyFormat()
38
    {
39
        return $this->moneyFormat;
40
    }
41
42
    protected function getNormalizedValue($value)
43
    {
44
        return money_format($this->getMoneyFormat(), $value);
45
    }
46
}
47