<?php
 namespace App\CurrencyExchange; class System_TcmbTR extends SystemAbstract { protected $referenceCurrency='TRY'; protected $systemAddress='https://www.tcmb.gov.tr/kurlar/today.xml'; public function getRates() { $responseString=$this->systemResponse(); $response=simplexml_load_string($responseString); if (!$response) throw new Exception("The external system's  reply was not a well formed XML."); $result=[]; if ($response->Currency) { foreach ($response->Currency as $thisCurr) { $curr=(String)$thisCurr['CurrencyCode']; $rate=(float)$thisCurr->ForexSelling; $mul=(float)$thisCurr->Unit; if ($mul>1) $realRate=$rate/$mul; else $realRate=$rate; if ($curr and $realRate>0) $result[$curr]=$realRate; } } return $result; } } 