protected function downloadExchangeRatesTable()
    {

        try {
            $this->table[$this->baseCurrency] = 1;

            $xml = simplexml_load_file($this->url, 'SimpleXMLElement', LIBXML_NOWARNING);

            if ($xml instanceof \SimpleXMLElement) {
                $data = $xml->xpath('//gesmes:Envelope/*[3]/*');
                foreach ($data[0]->children() as $child) {
                    $currency               = (string)$child->attributes()->currency;
                    $exchangeRate           = (string)$child->attributes()->rate;
                    $this->table[$currency] = $exchangeRate;
                }
            }
        } catch (\Exception $e) {
            throw new \RuntimeException('Cannot download rates from ECB.');
        }

    }
protected function downloadExchangeRatesTable()
    {

        try {
            $this->table[$this->baseCurrency] = 1;

            $xml = simplexml_load_file($this->url, 'SimpleXMLElement', LIBXML_NOWARNING);

            if ($xml instanceof \SimpleXMLElement) {
                $data = $xml->xpath('//gesmes:Envelope/*[3]/*');
                foreach ($data[0]->children() as $child) {
                    $currency               = (string)$child->attributes()->currency;
                    $exchangeRate           = (string)$child->attributes()->rate;
                    $this->table[$currency] = $exchangeRate;
                }
            }
        } catch (\Exception $e) {
            throw new \RuntimeException('Cannot download rates from ECB.');
        }

    }
protected function downloadExchangeRatesTable ( ) { try { $ this -> table [ $ this -> baseCurrency ] = 1 ; $ xml = simplexml_load_file ( $ this -> url , 'SimpleXMLElement' , LIBXML_NOWARNING ) ; if ( $ xml instanceof \ SimpleXMLElement ) { $ data = $ xml -> xpath ( '//gesmes:Envelope/*[3]/*' ) ; foreach ( $ data [ 0 ] -> children ( ) as $ child ) { $ currency = ( string ) $ child -> attributes ( ) -> currency ; $ exchangeRate = ( string ) $ child -> attributes ( ) -> rate ; $ this -> table [ $ currency ] = $ exchangeRate ; } } } catch ( \ Exception $ e ) { throw new \ RuntimeException ( 'Cannot download rates from ECB.' ) ; } }
Downloads exchange rates table from ECB
Downloads exchange rates table from ECB