Code Duplication    Length = 30-31 lines in 2 locations

src/Driver/XMLReader.php 2 locations

@@ 29-58 (lines=30) @@
26
     *
27
     * @return arry Array of \YMLParser\Node\Category instances or empty array
28
     */
29
    public function getCategories() {
30
        $returnArr = [];
31
        $this->moveToStart();
32
        $xml = $this->xml;
33
34
        while ($xml->read()) {
35
            if ($xml->nodeType == \XMLReader::ELEMENT && $xml->name == 'categories') {
36
                while ($xml->read() && $xml->name != 'categories') {
37
                    if ($xml->nodeType == \XMLReader::ELEMENT) {
38
                        $arr = [];
39
40
                        if ($xml->hasAttributes) {
41
42
                            while ($xml->moveToNextAttribute()) {
43
                                $arr[strtolower($xml->name)] = $xml->value;
44
                            }
45
                        }
46
47
                        $xml->read();
48
                        $arr['value'] = $xml->value;
49
                        $returnArr[] = new \YMLParser\Node\Category($arr);
50
51
                        unset($arr);
52
                    }
53
                }
54
            }
55
        }
56
57
        return $returnArr;
58
    }
59
60
    /**
61
     * Gets currencies.
@@ 65-95 (lines=31) @@
62
     *
63
     * @return array
64
     */
65
    public function getCurrencies() {
66
67
        $returnArr = [];
68
        $this->moveToStart();
69
        $xml = $this->xml;
70
71
        while ($xml->read()) {
72
            if ($xml->nodeType == \XMLReader::ELEMENT && $xml->name == 'currencies') {
73
                while ($xml->read() && $xml->name != 'currencies') {
74
                    if ($xml->nodeType == \XMLReader::ELEMENT) {
75
                        $arr = [];
76
77
                        if ($xml->hasAttributes) {
78
79
                            while ($xml->moveToNextAttribute()) {
80
                                $arr[strtolower($xml->name)] = $xml->value;
81
                            }
82
                        }
83
84
                        $xml->read();
85
                        $arr['value'] = $xml->value;
86
                        $returnArr[] = new \YMLParser\Node\Currency($arr);
87
88
                        unset($arr);
89
                    }
90
                }
91
            }
92
        }
93
94
        return $returnArr;
95
    }
96
97
    /**
98
     * Gets offers.