Code Duplication    Length = 12-13 lines in 4 locations

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

@@ 329-340 (lines=12) @@
326
                        if ($ProductClasses->count() < 1) {
327
                            // 規格分類1(ID)がセットされていると規格なし商品、規格あり商品を作成
328
                            $ProductClassOrg = $this->createProductClass($row, $Product, $data, $headerByKey);
329
                            if ($this->BaseInfo->isOptionProductDeliveryFee()) {
330
                                if (isset($row[$headerByKey['delivery_fee']]) && StringUtil::isNotBlank($row[$headerByKey['delivery_fee']])) {
331
                                    $deliveryFee = str_replace(',', '', $row[$headerByKey['delivery_fee']]);
332
                                    $errors = $this->validator->validate($deliveryFee, new GreaterThanOrEqual(['value' => 0]));
333
                                    if ($errors->count() === 0) {
334
                                        $ProductClassOrg->setDeliveryFee($deliveryFee);
335
                                    } else {
336
                                        $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['delivery_fee']]);
337
                                        $this->addErrors($message);
338
                                    }
339
                                }
340
                            }
341
342
                            // 商品別税率機能が有効の場合に税率を更新
343
                            if ($this->BaseInfo->isOptionProductTaxRule()) {
@@ 454-465 (lines=12) @@
451
                                ) {
452
                                    $this->updateProductClass($row, $Product, $pc, $data, $headerByKey);
453
454
                                    if ($this->BaseInfo->isOptionProductDeliveryFee()) {
455
                                        if (isset($row[$headerByKey['delivery_fee']]) && StringUtil::isNotBlank($row[$headerByKey['delivery_fee']])) {
456
                                            $deliveryFee = str_replace(',', '', $row[$headerByKey['delivery_fee']]);
457
                                            $errors = $this->validator->validate($deliveryFee, new GreaterThanOrEqual(['value' => 0]));
458
                                            if ($errors->count() === 0) {
459
                                                $pc->setDeliveryFee($deliveryFee);
460
                                            } else {
461
                                                $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['delivery_fee']]);
462
                                                $this->addErrors($message);
463
                                            }
464
                                        }
465
                                    }
466
467
                                    // 商品別税率機能が有効の場合に税率を更新
468
                                    if ($this->BaseInfo->isOptionProductTaxRule()) {
@@ 572-583 (lines=12) @@
569
                                    }
570
                                    $ProductClass = $this->createProductClass($row, $Product, $data, $headerByKey, $ClassCategory1, $ClassCategory2);
571
572
                                    if ($this->BaseInfo->isOptionProductDeliveryFee()) {
573
                                        if (isset($row[$headerByKey['delivery_fee']]) && StringUtil::isNotBlank($row[$headerByKey['delivery_fee']])) {
574
                                            $deliveryFee = str_replace(',', '', $row[$headerByKey['delivery_fee']]);
575
                                            $errors = $this->validator->validate($deliveryFee, new GreaterThanOrEqual(['value' => 0]));
576
                                            if ($errors->count() === 0) {
577
                                                $ProductClass->setDeliveryFee($deliveryFee);
578
                                            } else {
579
                                                $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['delivery_fee']]);
580
                                                $this->addErrors($message);
581
                                            }
582
                                        }
583
                                    }
584
585
                                    // 商品別税率機能が有効の場合に税率を更新
586
                                    if ($this->BaseInfo->isOptionProductTaxRule()) {
@@ 1139-1151 (lines=13) @@
1136
            $this->addErrors($message);
1137
        }
1138
1139
        if ($this->BaseInfo->isOptionProductDeliveryFee()) {
1140
            if (isset($row[$headerByKey['delivery_fee']]) && StringUtil::isNotBlank($row[$headerByKey['delivery_fee']])) {
1141
                $delivery_fee = str_replace(',', '', $row[$headerByKey['delivery_fee']]);
1142
                $errors = $this->validator->validate($delivery_fee, new GreaterThanOrEqual(['value' => 0]));
1143
                if ($errors->count() === 0) {
1144
                    $ProductClass->setDeliveryFee($delivery_fee);
1145
                } else {
1146
                    $message = trans('admin.common.csv_invalid_greater_than_zero',
1147
                        ['%line%' => $line, '%name%' => $headerByKey['delivery_fee']]);
1148
                    $this->addErrors($message);
1149
                }
1150
            }
1151
        }
1152
1153
        $Product->addProductClass($ProductClass);
1154
        $ProductStock = new ProductStock();