Example #1
0
 public function fetch(Connector $connector, EncapsulatedOptions $options = null)
 {
     $csv = $connector->fetch('http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.csv');
     $reader = Reader::createFromString($csv);
     foreach ($reader->fetchAssoc() as $row) {
         (yield $row);
     }
 }
 public function fetch(Connector $connector, EncapsulatedOptions $options = null)
 {
     $xmlString = $connector->fetch(self::URL);
     $xml = simplexml_load_string($xmlString);
     $ratesContainer = $xml->Cube->Cube;
     $date = $ratesContainer['time'];
     $rates = $ratesContainer->Cube;
     $currencies = function () use($rates) {
         /** @var \SimpleXMLElement[] $rates */
         foreach ($rates as $rate) {
             (yield ['currency' => (string) $rate['currency'], 'rate' => (double) $rate['rate']]);
         }
     };
     return new CurrencyRecords($currencies(), new \DateTimeImmutable($date), count($rates), $this);
 }