Code Duplication    Length = 24-24 lines in 2 locations

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

@@ 858-881 (lines=24) @@
855
            $ProductClass->setCode(null);
856
        }
857
858
        if ($row['在庫数無制限フラグ'] == '') {
859
            $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
860
        } else {
861
            if ($row['在庫数無制限フラグ'] == (string) Constant::DISABLED) {
862
                $ProductClass->setStockUnlimited(Constant::DISABLED);
863
                // 在庫数が設定されていなければエラー
864
                if ($row['在庫数'] == '') {
865
                    $this->addErrors(($data->key() + 1) . '行目の在庫数が設定されていません。');
866
                } else {
867
                    $stock = str_replace(',', '', $row['在庫数']);
868
                    if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
869
                        $ProductClass->setStock($stock);
870
                    } else {
871
                        $this->addErrors(($data->key() + 1) . '行目の在庫数は0以上の数値を設定してください。');
872
                    }
873
                }
874
875
            } else if ($row['在庫数無制限フラグ'] == (string) Constant::ENABLED) {
876
                $ProductClass->setStockUnlimited(Constant::ENABLED);
877
                $ProductClass->setStock(null);
878
            } else {
879
                $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
880
            }
881
        }
882
883
        if ($row['販売制限数'] != '') {
884
            $saleLimit = str_replace(',', '', $row['販売制限数']);
@@ 1020-1043 (lines=24) @@
1017
            $ProductClass->setCode(null);
1018
        }
1019
1020
        if ($row['在庫数無制限フラグ'] == '') {
1021
            $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
1022
        } else {
1023
            if ($row['在庫数無制限フラグ'] == (string) Constant::DISABLED) {
1024
                $ProductClass->setStockUnlimited(Constant::DISABLED);
1025
                // 在庫数が設定されていなければエラー
1026
                if ($row['在庫数'] == '') {
1027
                    $this->addErrors(($data->key() + 1) . '行目の在庫数が設定されていません。');
1028
                } else {
1029
                    $stock = str_replace(',', '', $row['在庫数']);
1030
                    if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
1031
                        $ProductClass->setStock($row['在庫数']);
1032
                    } else {
1033
                        $this->addErrors(($data->key() + 1) . '行目の在庫数は0以上の数値を設定してください。');
1034
                    }
1035
                }
1036
1037
            } else if ($row['在庫数無制限フラグ'] == (string) Constant::ENABLED) {
1038
                $ProductClass->setStockUnlimited(Constant::ENABLED);
1039
                $ProductClass->setStock(null);
1040
            } else {
1041
                $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
1042
            }
1043
        }
1044
1045
        if ($row['販売制限数'] != '') {
1046
            $saleLimit = str_replace(',', '', $row['販売制限数']);