Code Duplication    Length = 32-32 lines in 2 locations

src/Eccube/Service/PurchaseFlow/Processor/DeliveryFeeChangeValidator.php 1 location

@@ 25-56 (lines=32) @@
22
/**
23
 * 送料明細の金額とdtb_delivery_feeに登録されている送料の差異を検知するバリデータ.
24
 */
25
class DeliveryFeeChangeValidator extends ItemHolderPostValidator
26
{
27
    /**
28
     * @param ItemHolderInterface $itemHolder
29
     * @param PurchaseContext $context
30
     *
31
     * @throws InvalidItemException
32
     */
33
    protected function validate(ItemHolderInterface $itemHolder, PurchaseContext $context)
34
    {
35
        if (!$itemHolder instanceof Order) {
36
            return;
37
        }
38
39
        /** @var Order $originHolder */
40
        $originHolder = $context->getOriginHolder();
41
42
        // 受注の生成直後はチェックしない.
43
        if (!$originHolder->getOrderNo()) {
44
            return;
45
        }
46
47
        if ($originHolder->getDeliveryFeeTotal() != $itemHolder->getDeliveryFeeTotal()) {
48
            $this->throwInvalidItemException('purchase_flow.delivery_fee_update', null, true);
49
        }
50
    }
51
52
    public function __toString()
53
    {
54
        return get_class($this);
55
    }
56
}
57

src/Eccube/Service/PurchaseFlow/Processor/PaymentChargeChangeValidator.php 1 location

@@ 25-56 (lines=32) @@
22
/**
23
 * 手数料が変更されたかどうかを検知するバリデータ.
24
 */
25
class PaymentChargeChangeValidator extends ItemHolderPostValidator
26
{
27
    /**
28
     * @param ItemHolderInterface $itemHolder
29
     * @param PurchaseContext $context
30
     *
31
     * @throws InvalidItemException
32
     */
33
    protected function validate(ItemHolderInterface $itemHolder, PurchaseContext $context)
34
    {
35
        if (!$itemHolder instanceof Order) {
36
            return;
37
        }
38
39
        /** @var Order $originHolder */
40
        $originHolder = $context->getOriginHolder();
41
42
        // 受注の生成直後はチェックしない.
43
        if (!$originHolder->getOrderNo()) {
44
            return;
45
        }
46
47
        if ($originHolder->getCharge() != $itemHolder->getCharge()) {
48
            $this->throwInvalidItemException('purchase_flow.charge_update', null, true);
49
        }
50
    }
51
52
    public function __toString()
53
    {
54
        return get_class($this);
55
    }
56
}
57