Source of file Currency.php
Size: 0,735 Bytes - Last Modified: 2021-12-23T10:19:36+00:00
/var/www/docs.ssmods.com/process/src/code/Currency.php
123456789101112131415161718192021222324252627282930313233343536 | <?php /** * @file Currency * * Generic Currency functions * */ namespace SaltedHerring; use GuzzleHttp\Client; class Currency { public static function exchange($amount, $from = 'NZD', $to = 'CNY', $date = 'latest') { $client = new Client([ 'base_uri' => 'http://api.fixer.io/' ]); $query = array( 'base' => $from, 'symbols' => $to ); $response = $client->request( 'GET', $date, array( 'query' => $query ) ); $data = json_decode($response->getBody()); $amount = $data->rates->$to; return number_format($amount, 2, '.', ','); } } |