Code Duplication    Length = 26-27 lines in 2 locations

src/Eccube/Service/CartService.php 2 locations

@@ 338-364 (lines=27) @@
335
     * @param  CartItem $CartItem
336
     * @return \Eccube\Service\CartService
337
     */
338
    public function removeCartItem($CartItem)
339
    {
340
        $compareService = $this->generateCartCompareService();
341
        $this->cart->removeCartItemByCartItem($CartItem, $compareService);
342
343
        // 支払方法の再設定
344
        if ($this->BaseInfo->getOptionMultipleShipping() == Constant::ENABLED) {
345
346
            // 複数配送対応
347
            $productTypes = array();
348
            foreach ($this->getCart()->getCartItems() as $item) {
349
                /* @var $ProductClass \Eccube\Entity\ProductClass */
350
                $ProductClass = $item->getObject();
351
                $productTypes[] = $ProductClass->getProductType();
352
            }
353
354
            // 配送業者を取得
355
            $deliveries = $this->entityManager->getRepository('Eccube\Entity\Delivery')->getDeliveries($productTypes);
356
357
            // 支払方法を取得
358
            $payments = $this->entityManager->getRepository('Eccube\Entity\Payment')->findAllowedPayments($deliveries);
359
360
            $this->getCart()->setPayments($payments);
361
        }
362
363
        return $this;
364
    }
365
366
    /**
367
     *
@@ 627-652 (lines=26) @@
624
     * @param  string $productClassId
625
     * @return \Eccube\Service\CartService
626
     */
627
    public function removeProduct($productClassId)
628
    {
629
        $this->cart->removeCartItemByIdentifier('Eccube\Entity\ProductClass', (string)$productClassId);
630
631
        // 支払方法の再設定
632
        if ($this->BaseInfo->getOptionMultipleShipping() == Constant::ENABLED) {
633
634
            // 複数配送対応
635
            $productTypes = array();
636
            foreach ($this->getCart()->getCartItems() as $item) {
637
                /* @var $ProductClass \Eccube\Entity\ProductClass */
638
                $ProductClass = $item->getObject();
639
                $productTypes[] = $ProductClass->getProductType();
640
            }
641
642
            // 配送業者を取得
643
            $deliveries = $this->entityManager->getRepository('Eccube\Entity\Delivery')->getDeliveries($productTypes);
644
645
            // 支払方法を取得
646
            $payments = $this->entityManager->getRepository('Eccube\Entity\Payment')->findAllowedPayments($deliveries);
647
648
            $this->getCart()->setPayments($payments);
649
        }
650
651
        return $this;
652
    }
653
654
    /**
655
     * @param  string $error