Code Duplication    Length = 22-22 lines in 2 locations

system/modules/Exchange1c/objects/Parser/Item/Offer/Warehouse.php 1 location

@@ 26-47 (lines=22) @@
23
        }
24
    }
25
26
    function parseWarehouse($warehouseCount) {
27
        $count = $warehouseCount['@attributes']['КоличествоНаСкладе'];
28
        $objectId = \App::$cur->migrations->findObject((string)$warehouseCount['@attributes']['ИдСклада'], 'Ecommerce\Warehouse');
29
        if ($objectId) {
30
            $modelName = get_class($this->model);
31
            $warehouse = \Ecommerce\Item\Offer\Warehouse::get([[$modelName::index(), $this->model->pk()], [\Ecommerce\Warehouse::index(), $objectId->object_id]]);
32
            if (!$warehouse) {
33
                $warehouse = new \Ecommerce\Item\Offer\Warehouse([
34
                    $modelName::index() => $this->model->pk(),
35
                    \Ecommerce\Warehouse::index() => $objectId->object_id,
36
                    'count' => $count
37
                ]);
38
                $warehouse->save();
39
            } else {
40
                if ($warehouse->count != $count) {
41
                    $warehouse->count = $count;
42
                    $warehouse->save();
43
                }
44
            }
45
        }
46
47
    }
48
49
}
50

system/modules/Exchange1c/objects/Parser/Item/Offer/WarehouseNew.php 1 location

@@ 26-47 (lines=22) @@
23
        }
24
    }
25
26
    function parseWarehouse($warehouseCount) {
27
        $count = $warehouseCount['Количество'];
28
        $objectId = \App::$cur->migrations->findObject((string) $warehouseCount['Ид'], 'Ecommerce\Warehouse');
29
        if ($objectId) {
30
            $modelName = get_class($this->model);
31
            $warehouse = \Ecommerce\Item\Offer\Warehouse::get([[$modelName::index(), $this->model->pk()], [\Ecommerce\Warehouse::index(), $objectId->object_id]]);
32
            if (!$warehouse) {
33
                $warehouse = new \Ecommerce\Item\Offer\Warehouse([
34
                    $modelName::index() => $this->model->pk(),
35
                    \Ecommerce\Warehouse::index() => $objectId->object_id,
36
                    'count' => $count
37
                ]);
38
                $warehouse->save();
39
            } else {
40
                if ($warehouse->count != $count) {
41
                    $warehouse->count = $count;
42
                    $warehouse->save();
43
                }
44
            }
45
        }
46
47
    }
48
49
}
50