Currency   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 45
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCode() 0 4 1
A __construct() 0 5 1
A __toString() 0 4 1
A getFractionDigits() 0 4 1
1
<?php
2
3
namespace Assimtech\Money;
4
5
use Symfony\Component\Intl\Intl;
6
7
class Currency
8
{
9
    /**
10
     * @var string $code ISO 4217 alpha3 currency code
11
     */
12
    private $code;
13
14
    /**
15
     * @var integer $fractionDigits
16
     */
17
    private $fractionDigits;
18
19
    /**
20
     * @param string $code ISO 4217 alpha3 currency code
21
     */
22 10
    public function __construct($code)
23
    {
24 10
        $this->code = $code;
25 10
        $this->fractionDigits = Intl::getCurrencyBundle()->getFractionDigits($code);
26 10
    }
27
28
    /**
29
     * @return string
30
     */
31 1
    public function __toString()
32
    {
33 1
        return $this->code;
34
    }
35
36
    /**
37
     * @return string
38
     */
39 5
    public function getCode()
40
    {
41 5
        return $this->code;
42
    }
43
44
    /**
45
     * @return integer
46
     */
47 6
    public function getFractionDigits()
48
    {
49 6
        return $this->fractionDigits;
50
    }
51
}
52