@@ -94,12 +94,16 @@ |
||
| 94 | 94 | */ |
| 95 | 95 | public function getRateToUse($from, $to) |
| 96 | 96 | { |
| 97 | - if ($from == $to) return 1; |
|
| 97 | + if ($from == $to) { |
|
| 98 | + return 1; |
|
| 99 | + } |
|
| 98 | 100 | if ($this->database) { |
| 99 | 101 | // Get a currency rate from table |
| 100 | 102 | $result = $this->_currencyratesTable->find('all')->where(['from_currency' => $from, 'to_currency' => $to])->first(); |
| 101 | 103 | // If currency rate is in table and it doesn't have to be updated |
| 102 | - if ($result && $result->modified->wasWithinLast($this->refresh . ' hours')) return $rate = $result->rate; |
|
| 104 | + if ($result && $result->modified->wasWithinLast($this->refresh . ' hours')) { |
|
| 105 | + return $rate = $result->rate; |
|
| 106 | + } |
|
| 103 | 107 | // If currency rate is in table and it have to be updated |
| 104 | 108 | if ($result && !$result->modified->wasWithinLast($this->refresh . ' hours')) { |
| 105 | 109 | if ($rate = $this->_getRateFromAPI($from, $to)) { |
@@ -94,12 +94,16 @@ |
||
| 94 | 94 | */ |
| 95 | 95 | public function getRateToUse($from, $to) |
| 96 | 96 | { |
| 97 | - if ($from == $to) return 1; |
|
| 97 | + if ($from == $to) { |
|
| 98 | + return 1; |
|
| 99 | + } |
|
| 98 | 100 | if ($this->database) { |
| 99 | 101 | // Get a currency rate from table |
| 100 | 102 | $result = $this->_currencyratesTable->find('all')->where(['from_currency' => $from, 'to_currency' => $to])->first(); |
| 101 | 103 | // If currency rate is in table and it doesn't have to be updated |
| 102 | - if ($result && $result->modified->wasWithinLast($this->refresh . ' hours')) return $rate = $result->rate; |
|
| 104 | + if ($result && $result->modified->wasWithinLast($this->refresh . ' hours')) { |
|
| 105 | + return $rate = $result->rate; |
|
| 106 | + } |
|
| 103 | 107 | // If currency rate is in table and it have to be updated |
| 104 | 108 | if ($result && !$result->modified->wasWithinLast($this->refresh . ' hours')) { |
| 105 | 109 | if ($rate = $this->_getRateFromAPI($from, $to)) { |