Code Duplication    Length = 25-25 lines in 2 locations

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

@@ 1139-1163 (lines=25) @@
1136
            $ProductClass->setCode(null);
1137
        }
1138
1139
        if (!isset($row[$headerByKey['stock_unlimited']])
1140
            || StringUtil::isBlank($row[$headerByKey['stock_unlimited']])
1141
            || $row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED
1142
        ) {
1143
            $ProductClass->setStockUnlimited(false);
1144
            // 在庫数が設定されていなければエラー
1145
            if (isset($row[$headerByKey['stock']]) && StringUtil::isNotBlank($row[$headerByKey['stock']])) {
1146
                $stock = str_replace(',', '', $row[$headerByKey['stock']]);
1147
                if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
1148
                    $ProductClass->setStock($stock);
1149
                } else {
1150
                    $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1151
                    $this->addErrors($message);
1152
                }
1153
            } else {
1154
                $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1155
                $this->addErrors($message);
1156
            }
1157
        } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) {
1158
            $ProductClass->setStockUnlimited(true);
1159
            $ProductClass->setStock(null);
1160
        } else {
1161
            $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]);
1162
            $this->addErrors($message);
1163
        }
1164
1165
        if (isset($row[$headerByKey['sale_limit']]) && StringUtil::isNotBlank($row[$headerByKey['sale_limit']])) {
1166
            $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]);
@@ 1317-1341 (lines=25) @@
1314
            $ProductClass->setCode(null);
1315
        }
1316
1317
        if (!isset($row[$headerByKey['stock_unlimited']])
1318
            || StringUtil::isBlank($row[$headerByKey['stock_unlimited']])
1319
            || $row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED
1320
        ) {
1321
            $ProductClass->setStockUnlimited(false);
1322
            // 在庫数が設定されていなければエラー
1323
            if ($row[$headerByKey['stock']] == '') {
1324
                $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1325
                $this->addErrors($message);
1326
            } else {
1327
                $stock = str_replace(',', '', $row[$headerByKey['stock']]);
1328
                if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
1329
                    $ProductClass->setStock($row[$headerByKey['stock']]);
1330
                } else {
1331
                    $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1332
                    $this->addErrors($message);
1333
                }
1334
            }
1335
        } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) {
1336
            $ProductClass->setStockUnlimited(true);
1337
            $ProductClass->setStock(null);
1338
        } else {
1339
            $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]);
1340
            $this->addErrors($message);
1341
        }
1342
1343
        if (isset($row[$headerByKey['sale_limit']]) && $row[$headerByKey['sale_limit']] != '') {
1344
            $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]);