示例#1
0
 /**
  * Source currency
  * @param $source
  *
  * Destination currency
  * @param $destination
  *
  * Amount to convert
  * @param $amount
  */
 function convert($source, $destination, $amount)
 {
     $currencies = $this->source->fetch();
     if (!isset($currencies[$source])) {
         throw new \RuntimeException("Currency not found: {$source}");
     }
     if (!isset($currencies[$destination])) {
         throw new \RuntimeException("Currency not found: {$destination}");
     }
     return $amount * $currencies[$destination] / $currencies[$source];
 }
示例#2
0
文件: Table.php 项目: pracj3am/osto
 /**
  * Generates, executes SQL query and fetches the single row.
  * @return Entity|FALSE  array on success, FALSE if no next record
  */
 public function fetch()
 {
     $this->buildQuery();
     return $this->dataSource->fetch();
 }
示例#3
0
 function render()
 {
     return view('converter::index', ['endpoint' => config('currency.api_uri'), 'values' => $this->source->fetch()]);
 }