Currency::is()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.9332
cc 3
nc 3
nop 1
1
<?php
2
3
namespace GNAHotelSolutions\CurrencyConverter;
4
5
class Currency
6
{
7
    /** @var string */
8
    private $name;
9
10
    /** @var float */
11
    private $ratio;
12
13
    /** @var int */
14
    private $decimals;
15
16
    public function __construct(string $name, float $ratio, int $decimals)
17
    {
18
        $this->name = $name;
19
        $this->ratio = $ratio;
20
        $this->decimals = $decimals;
21
    }
22
23
    public function name(): string
24
    {
25
        return $this->name;
26
    }
27
28
    public function ratio(): float
29
    {
30
        return $this->ratio;
31
    }
32
33
    public function decimals(): int
34
    {
35
        return $this->decimals;
36
    }
37
38
    public function is(...$currencies): bool
39
    {
40
        foreach ($currencies as $currency) {
41
            if ($this->name() === $currency) {
42
                return true;
43
            }
44
        }
45
46
        return false;
47
    }
48
}
49