Code Duplication    Length = 16-16 lines in 2 locations

src/OroCRM/Bundle/SalesBundle/Form/Handler/LeadEmailHandler.php 1 location

@@ 98-113 (lines=16) @@
95
     * @param ApiEntityManager $manager
96
     * @throws \Exception
97
     */
98
    public function handleDelete($id, ApiEntityManager $manager)
99
    {
100
        /** @var LeadEmail $leadEmail */
101
        $leadEmail = $manager->find($id);
102
        if (!$this->securityFacade->isGranted('EDIT', $leadEmail->getOwner())) {
103
            throw new AccessDeniedException();
104
        }
105
106
        if ($leadEmail->isPrimary() && $leadEmail->getOwner()->getEmails()->count() === 1) {
107
            $em = $manager->getObjectManager();
108
            $em->remove($leadEmail);
109
            $em->flush();
110
        } else {
111
            throw new \Exception("orocrm.lead.email.error.delete.more_one", 500);
112
        }
113
    }
114
115
    /**
116
     * @param LeadEmail $entity

src/OroCRM/Bundle/SalesBundle/Form/Handler/LeadPhoneHandler.php 1 location

@@ 99-114 (lines=16) @@
96
     *
97
     * @throws \Exception
98
     */
99
    public function handleDelete($id, ApiEntityManager $manager)
100
    {
101
        /** @var LeadPhone $leadPhone */
102
        $leadPhone = $manager->find($id);
103
        if (!$this->securityFacade->isGranted('EDIT', $leadPhone->getOwner())) {
104
            throw new AccessDeniedException();
105
        }
106
107
        if ($leadPhone->isPrimary() && $leadPhone->getOwner()->getPhones()->count() === 1) {
108
            $em = $manager->getObjectManager();
109
            $em->remove($leadPhone);
110
            $em->flush();
111
        } else {
112
            throw new \Exception("orocrm.lead.phone.error.delete.more_one", 500);
113
        }
114
    }
115
116
    /**
117
     * @param LeadPhone $entity