Skip to content

Commit

Permalink
Merge pull request #129 from uguurozkan/master
Browse files Browse the repository at this point in the history
Normalize TCMB rates
  • Loading branch information
florianv committed Jan 18, 2021
2 parents e475379 + 74721ff commit cfc57b7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Service/CentralBankOfRepublicTurkey.php
Expand Up @@ -78,10 +78,13 @@ private function doCreateRate(ExchangeRateQuery $exchangeQuery, DateTimeInterfac
$element = StringUtil::xmlToElement($content);

$date = new \DateTime((string) $element->xpath('//Tarih_Date/@Date')[0]);
$elements = $element->xpath('//Currency[@CurrencyCode="'.$currencyPair->getBaseCurrency().'"]/ForexSelling');
$elements = $element->xpath('//Currency[@CurrencyCode="'.$currencyPair->getBaseCurrency().'"]');

if (!empty($elements) || !$date) {
return $this->createRate($currencyPair, (float) ($elements[0]), $date);
$rate = (float) $elements[0]->ForexSelling;
$unit = (int) $elements[0]->Unit ?? 1;

return $this->createRate($currencyPair, (float) ($rate / $unit), $date);
}

throw new UnsupportedCurrencyPairException($currencyPair, $this);
Expand Down

0 comments on commit cfc57b7

Please sign in to comment.