Code Duplication    Length = 10-10 lines in 3 locations

src/PlaygroundGame/Controller/Frontend/PostVoteController.php 2 locations

@@ 441-450 (lines=10) @@
438
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
439
        $form->setAttribute('method', 'post');
440
441
        if ($this->getRequest()->isPost()) {
442
            $data = $this->getRequest()->getPost()->toArray();
443
            $form->setData($data);
444
            if ($form->isValid()) {
445
                $result = $this->getGameService()->sendShareMail($data, $game, $user, $lastEntry);
446
                if ($result) {
447
                    $statusMail = true;
448
                }
449
            }
450
        }
451
452
        // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu.
453
        $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntry));
@@ 842-851 (lines=10) @@
839
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
840
        $form->setAttribute('method', 'post');
841
    
842
        if ($this->getRequest()->isPost()) {
843
            $data = $this->getRequest()->getPost()->toArray();
844
            $form->setData($data);
845
            if ($form->isValid()) {
846
                $result = $this->getGameService()->sendShareMail($data, $game, $user, $lastEntry);
847
                if ($result) {
848
                    $statusMail = true;
849
                }
850
            }
851
        }
852
853
        $viewModel = $this->buildView($game);
854
    

src/PlaygroundGame/Controller/Frontend/GameController.php 1 location

@@ 831-840 (lines=10) @@
828
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
829
        $form->setAttribute('method', 'post');
830
    
831
        if ($this->getRequest()->isPost()) {
832
            $data = $this->getRequest()->getPost()->toArray();
833
            $form->setData($data);
834
            if ($form->isValid()) {
835
                $result = $this->getGameService()->sendShareMail($data, $game, $user, $lastEntry);
836
                if ($result) {
837
                    $statusMail = true;
838
                }
839
            }
840
        }
841
    
842
        // buildView must be before sendMail because it adds the game template path to the templateStack
843
        $viewModel = $this->buildView($game);