Code Duplication    Length = 23-23 lines in 2 locations

src/Commands/AbstractPrestashopProductsImportCommand.php 1 location

@@ 106-128 (lines=23) @@
103
    /**
104
     * @return array
105
     */
106
    public function getProducts()
107
    {
108
        try {
109
            $xml = $this->prestashop->get([
110
                'resource' => self::PRESTASHOP_RESOURCE_NAME,
111
            ]);
112
        } catch (PrestashopWebServiceException $e) {
113
            $this->error('Prestashop: Failed to request products');
114
            return [];
115
        }
116
117
        $ids = [];
118
119
        foreach ($xml->products->children() as $product) {
120
            foreach ($product->attributes() as $key => $value) {
121
                if ($key === 'id') {
122
                    array_push($ids, (string)$value);
123
                }
124
            }
125
        }
126
127
        return $ids;
128
    }
129
130
    /**
131
     * @param string $id

src/Commands/AbstractPrestashopSuppliersImportCommand.php 1 location

@@ 83-105 (lines=23) @@
80
    /**
81
     * @return array
82
     */
83
    private function getSuppliers()
84
    {
85
        try {
86
            $xml = $this->prestashop->get([
87
                'resource' => self::PRESTASHOP_RESOURCE_NAME,
88
            ]);
89
        } catch (PrestashopWebServiceException $e) {
90
            $this->error('Prestashop: Failed to request suppliers');
91
            return [];
92
        }
93
94
        $ids = [];
95
96
        foreach ($xml->suppliers->children() as $supplier) {
97
            foreach ($supplier->attributes() as $key => $value) {
98
                if ($key === 'id') {
99
                    array_push($ids, (string) $value);
100
                }
101
            }
102
        }
103
104
        return $ids;
105
    }
106
107
    /**
108
     * @param string $id