Code Duplication    Length = 25-25 lines in 2 locations

src/Eccube/Controller/Admin/Product/CsvImportController.php 2 locations

@@ 1089-1113 (lines=25) @@
1086
            $ProductClass->setCode(null);
1087
        }
1088
1089
        if (!isset($row[$headerByKey['stock_unlimited']])
1090
            || StringUtil::isBlank($row[$headerByKey['stock_unlimited']])
1091
            || $row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED
1092
        ) {
1093
            $ProductClass->setStockUnlimited(false);
1094
            // 在庫数が設定されていなければエラー
1095
            if (isset($row[$headerByKey['stock']]) && StringUtil::isNotBlank($row[$headerByKey['stock']])) {
1096
                $stock = str_replace(',', '', $row[$headerByKey['stock']]);
1097
                if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
1098
                    $ProductClass->setStock($stock);
1099
                } else {
1100
                    $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1101
                    $this->addErrors($message);
1102
                }
1103
            } else {
1104
                $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1105
                $this->addErrors($message);
1106
            }
1107
        } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) {
1108
            $ProductClass->setStockUnlimited(true);
1109
            $ProductClass->setStock(null);
1110
        } else {
1111
            $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]);
1112
            $this->addErrors($message);
1113
        }
1114
1115
        if (isset($row[$headerByKey['sale_limit']]) && StringUtil::isNotBlank($row[$headerByKey['sale_limit']])) {
1116
            $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]);
@@ 1267-1291 (lines=25) @@
1264
            $ProductClass->setCode(null);
1265
        }
1266
1267
        if (!isset($row[$headerByKey['stock_unlimited']])
1268
            || StringUtil::isBlank($row[$headerByKey['stock_unlimited']])
1269
            || $row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED
1270
        ) {
1271
            $ProductClass->setStockUnlimited(false);
1272
            // 在庫数が設定されていなければエラー
1273
            if ($row[$headerByKey['stock']] == '') {
1274
                $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1275
                $this->addErrors($message);
1276
            } else {
1277
                $stock = str_replace(',', '', $row[$headerByKey['stock']]);
1278
                if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
1279
                    $ProductClass->setStock($row[$headerByKey['stock']]);
1280
                } else {
1281
                    $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1282
                    $this->addErrors($message);
1283
                }
1284
            }
1285
        } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) {
1286
            $ProductClass->setStockUnlimited(true);
1287
            $ProductClass->setStock(null);
1288
        } else {
1289
            $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]);
1290
            $this->addErrors($message);
1291
        }
1292
1293
        if ($row[$headerByKey['sale_limit']] != '') {
1294
            $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]);