Currency::getCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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