Code Duplication    Length = 29-29 lines in 2 locations

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

@@ 380-408 (lines=29) @@
377
                            }
378
379
                            // 商品別税率機能が有効の場合に税率を更新
380
                            if ($this->BaseInfo->isOptionProductTaxRule()) {
381
                                if (isset($row[$headerByKey['tax_rate']]) && StringUtil::isNotBlank($row[$headerByKey['tax_rate']])) {
382
                                    $taxRate = $row[$headerByKey['tax_rate']];
383
                                    $errors = $this->validator->validate($taxRate, new GreaterThanOrEqual(['value' => 0]));
384
                                    if ($errors->count() === 0) {
385
                                        if ($ProductClassOrg->getTaxRule()) {
386
                                            // 商品別税率の設定があれば税率を更新
387
                                            $ProductClassOrg->getTaxRule()->setTaxRate($taxRate);
388
                                        } else {
389
                                            // 商品別税率の設定がなければ新規作成
390
                                            $TaxRule = $this->taxRuleRepository->newTaxRule();
391
                                            $TaxRule->setTaxRate($taxRate);
392
                                            $TaxRule->setApplyDate(new \DateTime());
393
                                            $TaxRule->setProduct($Product);
394
                                            $TaxRule->setProductClass($ProductClassOrg);
395
                                            $ProductClassOrg->setTaxRule($TaxRule);
396
                                        }
397
                                    } else {
398
                                        $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['tax_rate']]);
399
                                        $this->addErrors($message);
400
                                    }
401
                                } else {
402
                                    // 税率の入力がなければ税率の設定を削除
403
                                    if ($ProductClassOrg->getTaxRule()) {
404
                                        $this->taxRuleRepository->delete($ProductClassOrg->getTaxRule());
405
                                        $ProductClassOrg->setTaxRule(null);
406
                                    }
407
                                }
408
                            }
409
410
                            if (isset($row[$headerByKey['class_category1']]) && StringUtil::isNotBlank($row[$headerByKey['class_category1']])) {
411
                                if (isset($row[$headerByKey['class_category2']]) && $row[$headerByKey['class_category1']] == $row[$headerByKey['class_category2']]) {
@@ 505-533 (lines=29) @@
502
                                    }
503
504
                                    // 商品別税率機能が有効の場合に税率を更新
505
                                    if ($this->BaseInfo->isOptionProductTaxRule()) {
506
                                        if (isset($row[$headerByKey['tax_rate']]) && StringUtil::isNotBlank($row[$headerByKey['tax_rate']])) {
507
                                            $taxRate = $row[$headerByKey['tax_rate']];
508
                                            $errors = $this->validator->validate($taxRate, new GreaterThanOrEqual(['value' => 0]));
509
                                            if ($errors->count() === 0) {
510
                                                if ($pc->getTaxRule()) {
511
                                                    // 商品別税率の設定があれば税率を更新
512
                                                    $pc->getTaxRule()->setTaxRate($taxRate);
513
                                                } else {
514
                                                    // 商品別税率の設定がなければ新規作成
515
                                                    $TaxRule = $this->taxRuleRepository->newTaxRule();
516
                                                    $TaxRule->setTaxRate($taxRate);
517
                                                    $TaxRule->setApplyDate(new \DateTime());
518
                                                    $TaxRule->setProduct($Product);
519
                                                    $TaxRule->setProductClass($pc);
520
                                                    $pc->setTaxRule($TaxRule);
521
                                                }
522
                                            } else {
523
                                                $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['tax_rate']]);
524
                                                $this->addErrors($message);
525
                                            }
526
                                        } else {
527
                                            // 税率の入力がなければ税率の設定を削除
528
                                            if ($pc->getTaxRule()) {
529
                                                $this->taxRuleRepository->delete($pc->getTaxRule());
530
                                                $pc->setTaxRule(null);
531
                                            }
532
                                        }
533
                                    }
534
535
                                    $flag = true;
536
                                    break;