CurrencyPair   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 59
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A currencyFrom() 0 4 1
A currencyTo() 0 4 1
A ratio() 0 4 1
A __construct() 0 7 1
A validateRatio() 0 6 2
1
<?php
2
3
namespace Kanunak\Money;
4
5
class CurrencyPair
6
{
7
    /** @var Currency  */
8
    private $currencyFrom;
9
10
    /** @var Currency  */
11
    private $currencyTo;
12
13
    /** @var  float */
14
    private $ratio;
15
16
    /**
17
     * @param Currency $currencyFrom
18
     * @param Currency $currencyTo
19
     * @param $ratio
20
     */
21
    public function __construct(Currency $currencyFrom, Currency $currencyTo, $ratio)
22
    {
23
        $this->validateRatio($ratio);
24
        $this->currencyFrom = $currencyFrom;
25
        $this->currencyTo = $currencyTo;
26
        $this->ratio = $ratio;
27
    }
28
29
    /**
30
     * @return Currency
31
     */
32
    public function currencyFrom()
33
    {
34
        return $this->currencyFrom;
35
    }
36
37
    /**
38
     * @return Currency
39
     */
40
    public function currencyTo()
41
    {
42
        return $this->currencyTo;
43
    }
44
45
    /**
46
     * @return float
47
     */
48
    public function ratio()
49
    {
50
        return $this->ratio;
51
    }
52
53
    /**
54
     * @param $ratio
55
     * @throw \InvalidArgumentException
56
     */
57
    private function validateRatio($ratio)
58
    {
59
        if (!is_float($ratio)) {
60
            throw new \InvalidArgumentException('Ratio is not float');
61
        }
62
    }
63
}
64