Code Duplication    Length = 11-17 lines in 2 locations

Importer/CentralAzerbaijanBank.php 1 location

@@ 38-54 (lines=17) @@
35
        $now = new \DateTime('now');
36
        $this->url = $this->url.$now->format('d.m.Y').'.xml';
37
        $xml = simplexml_load_file($this->url);
38
        if ($xml instanceof \SimpleXMLElement) {
39
            // base currency: AZN
40
            $this->updateOrCreate($managedCurrencies, $this->baseCurrency, 1.00);
41
42
            $data = $xml->xpath('//ValCurs/*[1]');
43
            // divides 1.00 by current exchange rate to get the reverse rate,
44
            // because CBAR provides only inverse rate
45
            foreach ($data[0]->children() as $child) {
46
                $this->updateOrCreate(
47
                    $managedCurrencies,
48
                    (string) $child->attributes()->Code,
49
                    1.00 / (float) $child->children()->Value
50
                );
51
            }
52
53
            $this->manager->flush();
54
        }
55
    }
56
}
57

Importer/EuropeanCentralBankImporter.php 1 location

@@ 35-45 (lines=11) @@
32
    public function import(array $managedCurrencies = array())
33
    {
34
        $xml = simplexml_load_file($this->url);
35
        if ($xml instanceof \SimpleXMLElement) {
36
            // base currency: euro
37
            $this->updateOrCreate($managedCurrencies, $this->baseCurrency, 1.00);
38
39
            $data = $xml->xpath('//gesmes:Envelope/*[3]/*');
40
            foreach ($data[0]->children() as $child) {
41
                $this->updateOrCreate($managedCurrencies, (string) $child->attributes()->currency, (float) $child->attributes()->rate);
42
            }
43
44
            $this->manager->flush();
45
        }
46
    }
47
48
    public function setBaseCurrency($baseCurrency = null)