Code Duplication    Length = 24-24 lines in 2 locations

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

@@ 910-933 (lines=24) @@
907
        if (StringUtil::isBlank($row[$headerByKey['stock_unlimited']])) {
908
            $message = trans('csvimportcontroller.require', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]);
909
            $this->addErrors($message);
910
        } else {
911
            if ($row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED) {
912
                $ProductClass->setStockUnlimited(false);
913
                // 在庫数が設定されていなければエラー
914
                if (isset($row[$headerByKey['stock']]) && StringUtil::isNotBlank($row[$headerByKey['stock']])) {
915
                    $stock = str_replace(',', '', $row[$headerByKey['stock']]);
916
                    if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
917
                        $ProductClass->setStock($stock);
918
                    } else {
919
                        $message = trans('csvimportcontroller.great_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
920
                        $this->addErrors($message);
921
                    }
922
                } else {
923
                    $message = trans('csvimportcontroller.require', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
924
                    $this->addErrors($message);
925
                }
926
            } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) {
927
                $ProductClass->setStockUnlimited(true);
928
                $ProductClass->setStock(null);
929
            } else {
930
                $message = trans('csvimportcontroller.require', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]);
931
                $this->addErrors($message);
932
            }
933
        }
934
935
        if (isset($row[$headerByKey['sale_limit']]) && StringUtil::isNotBlank($row[$headerByKey['sale_limit']])) {
936
            $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]);
@@ 1084-1107 (lines=24) @@
1081
        if ($row[$headerByKey['stock_unlimited']] == '') {
1082
            $message = trans('csvimportcontroller.require', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]);
1083
            $this->addErrors($message);
1084
        } else {
1085
            if ($row[$headerByKey['stock_unlimited']] == (string) Constant::DISABLED) {
1086
                $ProductClass->setStockUnlimited(false);
1087
                // 在庫数が設定されていなければエラー
1088
                if ($row[$headerByKey['stock']] == '') {
1089
                    $message = trans('csvimportcontroller.require', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1090
                    $this->addErrors($message);
1091
                } else {
1092
                    $stock = str_replace(',', '', $row[$headerByKey['stock']]);
1093
                    if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
1094
                        $ProductClass->setStock($row[$headerByKey['stock']]);
1095
                    } else {
1096
                        $message = trans('csvimportcontroller.great_than_zero', ['%line%' => $line, '%name%' => $headerByKey['stock']]);
1097
                        $this->addErrors($message);
1098
                    }
1099
                }
1100
            } elseif ($row[$headerByKey['stock_unlimited']] == (string) Constant::ENABLED) {
1101
                $ProductClass->setStockUnlimited(true);
1102
                $ProductClass->setStock(null);
1103
            } else {
1104
                $message = trans('csvimportcontroller.require', ['%line%' => $line, '%name%' => $headerByKey['stock_unlimited']]);
1105
                $this->addErrors($message);
1106
            }
1107
        }
1108
1109
        if ($row[$headerByKey['sale_limit']] != '') {
1110
            $saleLimit = str_replace(',', '', $row[$headerByKey['sale_limit']]);