Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Utility;
  4.  
  5.  
  6. class Utility
  7. {
  8. //... Declaration of Constants
  9.  
  10. //... Declaration of curlExchangeRates function
  11.  
  12. protected function processExchangeRates(string $curlResponse, \DateTime $earliestDate = null){
  13. $delimiter = ($earliestDate ? $earliestDate : new \DateTime('-20 years'))->format('n/j/Y');
  14. //split the string into an array based on the delimiter. The first string in the array is the rate string we need
  15. $ratesString = preg_split(sprintf('("%s")',$delimiter), $curlResponse, 2)[0];
  16.  
  17. $headerPattern = '("Rate Date","Currency","Rate Year","Rate Month","Buying Rate","Central Rate","Selling Rate"\r\n)';
  18. //remove the first line in our rate string and return the result
  19. return preg_replace($headerPattern, '', $ratesString);
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement