Code Duplication    Length = 24-24 lines in 2 locations

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

@@ 846-869 (lines=24) @@
843
            $ProductClass->setCode(null);
844
        }
845
846
        if ($row['在庫数無制限フラグ'] == '') {
847
            $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
848
        } else {
849
            if ($row['在庫数無制限フラグ'] == (string) Constant::DISABLED) {
850
                $ProductClass->setStockUnlimited(Constant::DISABLED);
851
                // 在庫数が設定されていなければエラー
852
                if ($row['在庫数'] == '') {
853
                    $this->addErrors(($data->key() + 1) . '行目の在庫数が設定されていません。');
854
                } else {
855
                    $stock = str_replace(',', '', $row['在庫数']);
856
                    if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
857
                        $ProductClass->setStock($stock);
858
                    } else {
859
                        $this->addErrors(($data->key() + 1) . '行目の在庫数は0以上の数値を設定してください。');
860
                    }
861
                }
862
863
            } else if ($row['在庫数無制限フラグ'] == (string) Constant::ENABLED) {
864
                $ProductClass->setStockUnlimited(Constant::ENABLED);
865
                $ProductClass->setStock(null);
866
            } else {
867
                $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
868
            }
869
        }
870
871
        if ($row['販売制限数'] != '') {
872
            $saleLimit = str_replace(',', '', $row['販売制限数']);
@@ 1008-1031 (lines=24) @@
1005
            $ProductClass->setCode(null);
1006
        }
1007
1008
        if ($row['在庫数無制限フラグ'] == '') {
1009
            $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
1010
        } else {
1011
            if ($row['在庫数無制限フラグ'] == (string) Constant::DISABLED) {
1012
                $ProductClass->setStockUnlimited(Constant::DISABLED);
1013
                // 在庫数が設定されていなければエラー
1014
                if ($row['在庫数'] == '') {
1015
                    $this->addErrors(($data->key() + 1) . '行目の在庫数が設定されていません。');
1016
                } else {
1017
                    $stock = str_replace(',', '', $row['在庫数']);
1018
                    if (preg_match('/^\d+$/', $stock) && $stock >= 0) {
1019
                        $ProductClass->setStock($row['在庫数']);
1020
                    } else {
1021
                        $this->addErrors(($data->key() + 1) . '行目の在庫数は0以上の数値を設定してください。');
1022
                    }
1023
                }
1024
1025
            } else if ($row['在庫数無制限フラグ'] == (string) Constant::ENABLED) {
1026
                $ProductClass->setStockUnlimited(Constant::ENABLED);
1027
                $ProductClass->setStock(null);
1028
            } else {
1029
                $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
1030
            }
1031
        }
1032
1033
        if ($row['販売制限数'] != '') {
1034
            $saleLimit = str_replace(',', '', $row['販売制限数']);