Code Duplication    Length = 25-25 lines in 2 locations

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

@@ 967-991 (lines=25) @@
964
            $ProductClass->setCode(null);
965
        }
966
967
        if (!isset($row[$headerByKey['stock_unlimited']])
968
            || StringUtil::isBlank($row[$headerByKey['stock_unlimited']])
969
            || $row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED
970
        ) {
971
            $ProductClass->setStockUnlimited(false);
972
            // 在庫数が設定されていなければエラー
973
            if (isset($row[$headerByKey['stock']]) && StringUtil::isNotBlank($row[$headerByKey['stock']])) {
974
                $stock = str_replace(',', '', $row[$headerByKey['stock']]);
975
                if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
976
                    $ProductClass->setStock($stock);
977
                } else {
978
                    $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
979
                    $this->addErrors($message);
980
                }
981
            } else {
982
                $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
983
                $this->addErrors($message);
984
            }
985
        } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) {
986
            $ProductClass->setStockUnlimited(true);
987
            $ProductClass->setStock(null);
988
        } else {
989
            $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]);
990
            $this->addErrors($message);
991
        }
992
993
        if (isset($row[$headerByKey['sale_limit']]) && StringUtil::isNotBlank($row[$headerByKey['sale_limit']])) {
994
            $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]);
@@ 1142-1166 (lines=25) @@
1139
            $ProductClass->setCode(null);
1140
        }
1141
1142
        if (!isset($row[$headerByKey['stock_unlimited']])
1143
            || StringUtil::isBlank($row[$headerByKey['stock_unlimited']])
1144
            || $row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED
1145
        ) {
1146
            $ProductClass->setStockUnlimited(false);
1147
            // 在庫数が設定されていなければエラー
1148
            if ($row[$headerByKey['stock']] == '') {
1149
                $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1150
                $this->addErrors($message);
1151
            } else {
1152
                $stock = str_replace(',', '', $row[$headerByKey['stock']]);
1153
                if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
1154
                    $ProductClass->setStock($row[$headerByKey['stock']]);
1155
                } else {
1156
                    $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1157
                    $this->addErrors($message);
1158
                }
1159
            }
1160
        } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) {
1161
            $ProductClass->setStockUnlimited(true);
1162
            $ProductClass->setStock(null);
1163
        } else {
1164
            $message = trans('admin.common.csv_invalid_required', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]);
1165
            $this->addErrors($message);
1166
        }
1167
1168
        if ($row[$headerByKey['sale_limit']] != '') {
1169
            $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]);