Code Duplication    Length = 24-24 lines in 2 locations

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

@@ 770-793 (lines=24) @@
767
            $ProductClass->setCode(null);
768
        }
769
770
        if ($row['在庫数無制限フラグ'] == '') {
771
            $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
772
        } else {
773
            if ($row['在庫数無制限フラグ'] == (string) Constant::DISABLED) {
774
                $ProductClass->setStockUnlimited(Constant::DISABLED);
775
                // 在庫数が設定されていなければエラー
776
                if ($row['在庫数'] == '') {
777
                    $this->addErrors(($data->key() + 1) . '行目の在庫数が設定されていません。');
778
                } else {
779
                    $stock = str_replace(',', '', $row['在庫数']);
780
                    if (is_numeric($stock) && $stock >= 0) {
781
                        $ProductClass->setStock($stock);
782
                    } else {
783
                        $this->addErrors(($data->key() + 1) . '行目の在庫数は0以上の数値を設定してください。');
784
                    }
785
                }
786
787
            } else if ($row['在庫数無制限フラグ'] == (string) Constant::ENABLED) {
788
                $ProductClass->setStockUnlimited(Constant::ENABLED);
789
                $ProductClass->setStock(null);
790
            } else {
791
                $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
792
            }
793
        }
794
795
        if ($row['販売制限数'] != '') {
796
            $saleLimit = str_replace(',', '', $row['販売制限数']);
@@ 932-955 (lines=24) @@
929
            $ProductClass->setCode(null);
930
        }
931
932
        if ($row['在庫数無制限フラグ'] == '') {
933
            $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
934
        } else {
935
            if ($row['在庫数無制限フラグ'] == (string) Constant::DISABLED) {
936
                $ProductClass->setStockUnlimited(Constant::DISABLED);
937
                // 在庫数が設定されていなければエラー
938
                if ($row['在庫数'] == '') {
939
                    $this->addErrors(($data->key() + 1) . '行目の在庫数が設定されていません。');
940
                } else {
941
                    $stock = str_replace(',', '', $row['在庫数']);
942
                    if (is_numeric($stock) && $stock >= 0) {
943
                        $ProductClass->setStock($row['在庫数']);
944
                    } else {
945
                        $this->addErrors(($data->key() + 1) . '行目の在庫数は0以上の数値を設定してください。');
946
                    }
947
                }
948
949
            } else if ($row['在庫数無制限フラグ'] == (string) Constant::ENABLED) {
950
                $ProductClass->setStockUnlimited(Constant::ENABLED);
951
                $ProductClass->setStock(null);
952
            } else {
953
                $this->addErrors(($data->key() + 1) . '行目の在庫数無制限フラグが設定されていません。');
954
            }
955
        }
956
957
        if ($row['販売制限数'] != '') {
958
            $saleLimit = str_replace(',', '', $row['販売制限数']);