@@ -44,12 +44,12 @@ |
||
| 44 | 44 | ->maxLength('from', 5) |
| 45 | 45 | ->notEmpty('from'); |
| 46 | 46 | |
| 47 | - $validator |
|
| 47 | + $validator |
|
| 48 | 48 | ->scalar('to') |
| 49 | 49 | ->maxLength('to', 5) |
| 50 | 50 | ->notEmpty('to'); |
| 51 | 51 | |
| 52 | - $validator |
|
| 52 | + $validator |
|
| 53 | 53 | ->scalar('rate') |
| 54 | 54 | ->maxLength('rate', 10) |
| 55 | 55 | ->notEmpty('rate'); |
@@ -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)) { |
@@ -84,12 +84,16 @@ |
||
| 84 | 84 | */ |
| 85 | 85 | public function getRateToUse($from, $to) |
| 86 | 86 | { |
| 87 | - if ($from == $to) return 1; |
|
| 87 | + if ($from == $to) { |
|
| 88 | + return 1; |
|
| 89 | + } |
|
| 88 | 90 | if ($this->database) { |
| 89 | 91 | // Get a currency rate from table |
| 90 | 92 | $result = $this->_currencyratesTable->find('all')->where(['from_currency' => $from, 'to_currency' => $to])->first(); |
| 91 | 93 | // If currency rate is in table and it doesn't have to be updated |
| 92 | - if ($result && $result->modified->wasWithinLast($this->refresh . ' hours')) return $rate = $result->rate; |
|
| 94 | + if ($result && $result->modified->wasWithinLast($this->refresh . ' hours')) { |
|
| 95 | + return $rate = $result->rate; |
|
| 96 | + } |
|
| 93 | 97 | // If currency rate is in table and it have to be updated |
| 94 | 98 | if ($result && !$result->modified->wasWithinLast($this->refresh . ' hours')) { |
| 95 | 99 | if ($rate = $this->_getRateFromAPI($from, $to)) { |