| Total Complexity | 5 | 
| Total Lines | 36 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 4 | class Money | ||
| 5 | { | ||
| 6 | public $log; | ||
| 7 | |||
| 8 | public function __construct() | ||
| 9 |     { | ||
| 10 |         $this->log = new Log('class.money'); | ||
| 11 | } | ||
| 12 | |||
| 13 | public function getConvRate($from_currency, $to_currency) | ||
| 14 |     { | ||
| 15 | list($currency_slug, $full_url) = $this->getConvUrl($from_currency, $to_currency); | ||
| 16 | $remote = new Remote(); | ||
| 17 |         $result = $remote->getFileContents('Currency Conversion', 'error', $full_url); | ||
| 18 | $json_result = json_decode($result); | ||
| 19 |         $conversion_rate = $json_result->{$currency_slug}->val; | ||
| 20 | |||
| 21 |         if (!is_null($conversion_rate) && $conversion_rate != '') { | ||
| 22 | |||
| 23 | return $conversion_rate; | ||
| 24 | |||
| 25 |         } else { | ||
| 26 | |||
| 27 | $log_message = 'Unable to retrieve Currency Converter API (FREE) currency conversion'; | ||
| 28 |             $log_extra = array('From Currency' => $from_currency, 'To Currency' => $to_currency, | ||
| 29 | 'Conversion Rate Result' => $conversion_rate); | ||
| 30 | $this->log->critical($log_message, $log_extra); | ||
| 31 | return $log_message; | ||
| 32 | |||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | public function getConvUrl($from_currency, $to_currency) | ||
| 40 | } | ||
| 41 | } | ||
| 42 |