Code Duplication    Length = 19-19 lines in 2 locations

Controller/MailHookController.php 2 locations

@@ 20-38 (lines=19) @@
17
     * @Route("/{secretSalt}/{service}/catch", name="swm_mailhook_catcher_for_service")
18
     * @Method({"POST","GET"})
19
     */
20
    public function catcherAction($secretSalt, $service = null)
21
    {
22
        // check if request is granted
23
        $this->checkSecret($secretSalt);
24
25
        $mailHookService = $this->get('swm.mail_hook.service.mail_hook');
26
27
        // get hooks
28
        $hooks = $mailHookService->getHooksForService($service);
29
30
        $eventHydrator = $this->get('swm.mail_hook.hydrator.default');
31
32
        foreach ($hooks as $hook) {
33
            $event = $eventHydrator->hydrate($hook, 'Swm\Bundle\MailHookBundle\Event\MailHookEvent');
34
            $this->get('event_dispatcher')->dispatch($hook->getEventDispatched(), $event);
35
        }
36
37
        return new Response();
38
    }
39
40
    /**
41
     * @Route("/{secretSalt}/{service}/catchuser", name="swm_mailhook_user_catcher_for_service")
@@ 44-62 (lines=19) @@
41
     * @Route("/{secretSalt}/{service}/catchuser", name="swm_mailhook_user_catcher_for_service")
42
     * @Method({"POST","GET"})
43
     */
44
    public function catchUserAction($secretSalt, $service = null)
45
    {
46
        // check if request is granted
47
        $this->checkSecret($secretSalt);
48
49
        $mailHookService = $this->get('swm.mail_hook.service.mail_hook');
50
51
        // get hooks
52
        $hooks = $mailHookService->getHooksForService($service);
53
54
        $eventHydrator = $this->get('swm.mail_hook.hydrator.fos_user');
55
56
        foreach ($hooks as $hook) {
57
            $event = $eventHydrator->hydrate($hook, 'Swm\Bundle\MailHookBundle\Event\UserMailHookEvent');
58
            $this->get('event_dispatcher')->dispatch($hook->getEventDispatched(), $event);
59
        }
60
61
        return new Response();
62
    }
63
64
    private function checkSecret($secretSalt)
65
    {