Exchange   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 31
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A rate() 0 7 2
1
<?php
2
3
namespace Rdehnhardt\ExchangeRate;
4
5
use Rdehnhardt\ExchangeRate\Excaptions\NotFoundException;
6
7
class Exchange
8
{
9
    /**
10
     * @var Fixer
11
     */
12
    private $fixer;
13
14
    /**
15
     * Exchange constructor.
16
     * @param Fixer $fixer
17
     */
18
    public function __construct(Fixer $fixer)
19
    {
20
        $this->fixer = $fixer;
21
    }
22
23
    /**
24
     * @param $amount
25
     * @param $from
26
     * @param $to
27
     * @param null $rate
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $rate is correct as it would always require null to be passed?
Loading history...
28
     * @return int
29
     * @throws NotFoundException
30
     */
31
    public function rate($amount, $from, $to, $rate = null)
32
    {
33
        if ($rate === null) {
34
            $rate = $this->fixer->get($from, $to);
35
        }
36
37
        return $amount * $rate;
38
    }
39
}
40