Code Duplication    Length = 24-24 lines in 2 locations

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

@@ 868-891 (lines=24) @@
865
            $ProductClass->setCode(null);
866
        }
867
868
        if ($row['在庫数無制限フラグ'] == '') {
869
            $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
870
        } else {
871
            if ($row['在庫数無制限フラグ'] == (string) Constant::DISABLED) {
872
                $ProductClass->setStockUnlimited(Constant::DISABLED);
873
                // 在庫数が設定されていなければエラー
874
                if ($row['在庫数'] == '') {
875
                    $this->addErrors(($data->key() + 1) . '行目の在庫数が設定されていません。');
876
                } else {
877
                    $stock = str_replace(',', '', $row['在庫数']);
878
                    if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
879
                        $ProductClass->setStock($stock);
880
                    } else {
881
                        $this->addErrors(($data->key() + 1) . '行目の在庫数は0以上の数値を設定してください。');
882
                    }
883
                }
884
885
            } else if ($row['在庫数無制限フラグ'] == (string) Constant::ENABLED) {
886
                $ProductClass->setStockUnlimited(Constant::ENABLED);
887
                $ProductClass->setStock(null);
888
            } else {
889
                $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
890
            }
891
        }
892
893
        if ($row['販売制限数'] != '') {
894
            $saleLimit = str_replace(',', '', $row['販売制限数']);
@@ 1030-1053 (lines=24) @@
1027
            $ProductClass->setCode(null);
1028
        }
1029
1030
        if ($row['在庫数無制限フラグ'] == '') {
1031
            $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
1032
        } else {
1033
            if ($row['在庫数無制限フラグ'] == (string) Constant::DISABLED) {
1034
                $ProductClass->setStockUnlimited(Constant::DISABLED);
1035
                // 在庫数が設定されていなければエラー
1036
                if ($row['在庫数'] == '') {
1037
                    $this->addErrors(($data->key() + 1) . '行目の在庫数が設定されていません。');
1038
                } else {
1039
                    $stock = str_replace(',', '', $row['在庫数']);
1040
                    if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
1041
                        $ProductClass->setStock($row['在庫数']);
1042
                    } else {
1043
                        $this->addErrors(($data->key() + 1) . '行目の在庫数は0以上の数値を設定してください。');
1044
                    }
1045
                }
1046
1047
            } else if ($row['在庫数無制限フラグ'] == (string) Constant::ENABLED) {
1048
                $ProductClass->setStockUnlimited(Constant::ENABLED);
1049
                $ProductClass->setStock(null);
1050
            } else {
1051
                $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
1052
            }
1053
        }
1054
1055
        if ($row['販売制限数'] != '') {
1056
            $saleLimit = str_replace(',', '', $row['販売制限数']);