Currency   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 37
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A __toString() 0 4 1
A getCode() 0 4 1
A getFractionDigits() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Assimtech\Fiat;
6
7
use Symfony\Component\Intl;
8
9
class Currency
10
{
11
    /**
12
     * @var string $code ISO 4217 alpha3 currency code
13
     */
14
    private $code;
15
16
    private $fractionDigits;
17
18
    /**
19
     * @param string $code ISO 4217 alpha3 currency code
20
     */
21 10
    public function __construct(
22
        string $code
23
    ) {
24 10
        $this->code = $code;
25 10
        $this->fractionDigits = \class_exists(Intl\Currencies::class)
26 10
            ? Intl\Currencies::getFractionDigits($code)
27
            : Intl\Intl::getCurrencyBundle()->getFractionDigits($code)
0 ignored issues
show
Bug introduced by
The method getCurrencyBundle() does not seem to exist on object<Symfony\Component\Intl\Intl>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28 1
        ;
29
    }
30 1
31
    public function __toString(): string
32
    {
33 5
        return $this->code;
34
    }
35 5
36
    public function getCode(): string
37
    {
38 6
        return $this->code;
39
    }
40 6
41
    public function getFractionDigits(): int
42
    {
43
        return $this->fractionDigits;
44
    }
45
}
46