Passed
Push — master ( 25c805...999286 )
by Andy
02:56 queued 11s
created

MoneyNormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 20
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setMoneyFormat() 0 5 1
A getMoneyFormat() 0 3 1
A getNormalizedValue() 0 3 1
1
<?php
2
3
namespace Palmtree\Csv\Normalizer;
4
5
class MoneyNormalizer extends AbstractNormalizer
6
{
7
    /** @var string */
8
    private $moneyFormat = '%.2n';
9
10
    public function setMoneyFormat(string $moneyFormat): self
11
    {
12
        $this->moneyFormat = $moneyFormat;
13
14
        return $this;
15
    }
16
17
    public function getMoneyFormat(): string
18
    {
19
        return $this->moneyFormat;
20
    }
21
22
    protected function getNormalizedValue(string $value): string
23
    {
24
        return \money_format($this->getMoneyFormat(), (float)$value);
25
    }
26
}
27