Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3.009 |
Changes | 0 |
1 | <?php |
||
21 | 3 | public function getRates(string $fromCurrency, string $toCurrency) :float |
|
22 | { |
||
23 | 3 | $this->apiCaller->convert( |
|
24 | $fromCurrency, |
||
25 | $toCurrency |
||
26 | ); |
||
27 | |||
28 | 2 | if ($this->apiCaller->isLastCallEmpty()) { |
|
29 | 1 | return 0; |
|
30 | } |
||
31 | |||
32 | 1 | $result = $this->apiCaller->getLastResponse(); |
|
33 | |||
34 | 1 | $conversion = json_decode($result, true); |
|
35 | 1 | $key = $fromCurrency . '_' . $toCurrency; |
|
36 | |||
37 | 1 | if (!isset($conversion[$key])) { |
|
38 | return 0; |
||
39 | } |
||
40 | |||
41 | 1 | return $conversion[$fromCurrency . '_' . $toCurrency]; |
|
42 | } |
||
43 | |||
45 |