Code Duplication    Length = 15-15 lines in 4 locations

src/Eccube/Doctrine/EventSubscriber/TaxRuleEventSubscriber.php 4 locations

@@ 56-70 (lines=15) @@
53
        );
54
    }
55
56
    public function prePersist(LifecycleEventArgs $args)
57
    {
58
        $entity = $args->getObject();
59
60
        if ($entity instanceof ProductClass) {
61
            $entity->setPrice01IncTax($this->taxRateService->getPriceIncTax($entity->getPrice01(), $entity->getProduct(), $entity));
62
            $entity->setPrice02IncTax($this->taxRateService->getPriceIncTax($entity->getPrice02(), $entity->getProduct(), $entity));
63
        }
64
        if ($entity instanceof OrderDetail) {
65
            $entity->setPriceIncTax($entity->getPrice() + $this->taxRateService->calcTax($entity->getPrice(), $entity->getTaxRate(), $entity->getTaxRule()));
66
        }
67
        if ($entity instanceof ShipmentItem) {
68
            $entity->setPriceIncTax($this->taxRateService->getPriceIncTax($entity->getPrice(), $entity->getProduct(), $entity->getProductClass()));
69
        }
70
    }
71
72
    public function postLoad(LifecycleEventArgs $args)
73
    {
@@ 72-86 (lines=15) @@
69
        }
70
    }
71
72
    public function postLoad(LifecycleEventArgs $args)
73
    {
74
        $entity = $args->getObject();
75
76
        if ($entity instanceof ProductClass) {
77
            $entity->setPrice01IncTax($this->taxRateService->getPriceIncTax($entity->getPrice01(), $entity->getProduct(), $entity));
78
            $entity->setPrice02IncTax($this->taxRateService->getPriceIncTax($entity->getPrice02(), $entity->getProduct(), $entity));
79
        }
80
        if ($entity instanceof OrderDetail) {
81
            $entity->setPriceIncTax($entity->getPrice() + $this->taxRateService->calcTax($entity->getPrice(), $entity->getTaxRate(), $entity->getTaxRule()));
82
        }
83
        if ($entity instanceof ShipmentItem) {
84
            $entity->setPriceIncTax($this->taxRateService->getPriceIncTax($entity->getPrice(), $entity->getProduct(), $entity->getProductClass()));
85
        }
86
    }
87
88
    public function postPersist(LifecycleEventArgs $args)
89
    {
@@ 88-102 (lines=15) @@
85
        }
86
    }
87
88
    public function postPersist(LifecycleEventArgs $args)
89
    {
90
        $entity = $args->getObject();
91
92
        if ($entity instanceof ProductClass) {
93
            $entity->setPrice01IncTax($this->taxRateService->getPriceIncTax($entity->getPrice01(), $entity->getProduct(), $entity));
94
            $entity->setPrice02IncTax($this->taxRateService->getPriceIncTax($entity->getPrice02(), $entity->getProduct(), $entity));
95
        }
96
        if ($entity instanceof OrderDetail) {
97
            $entity->setPriceIncTax($entity->getPrice() + $this->taxRateService->calcTax($entity->getPrice(), $entity->getTaxRate(), $entity->getTaxRule()));
98
        }
99
        if ($entity instanceof ShipmentItem) {
100
            $entity->setPriceIncTax($this->taxRateService->getPriceIncTax($entity->getPrice(), $entity->getProduct(), $entity->getProductClass()));
101
        }
102
    }
103
104
    public function postUpdate(LifecycleEventArgs $args)
105
    {
@@ 104-118 (lines=15) @@
101
        }
102
    }
103
104
    public function postUpdate(LifecycleEventArgs $args)
105
    {
106
        $entity = $args->getObject();
107
108
        if ($entity instanceof ProductClass) {
109
            $entity->setPrice01IncTax($this->taxRateService->getPriceIncTax($entity->getPrice01(), $entity->getProduct(), $entity));
110
            $entity->setPrice02IncTax($this->taxRateService->getPriceIncTax($entity->getPrice02(), $entity->getProduct(), $entity));
111
        }
112
        if ($entity instanceof OrderDetail) {
113
            $entity->setPriceIncTax($entity->getPrice() + $this->taxRateService->calcTax($entity->getPrice(), $entity->getTaxRate(), $entity->getTaxRule()));
114
        }
115
        if ($entity instanceof ShipmentItem) {
116
            $entity->setPriceIncTax($this->taxRateService->getPriceIncTax($entity->getPrice(), $entity->getProduct(), $entity->getProductClass()));
117
        }
118
    }
119
}
120