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