Code Duplication    Length = 21-22 lines in 2 locations

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

@@ 706-727 (lines=22) @@
703
        $response = $this->getResponse();
704
        $post = $this->getGameService()->getPostvotePostMapper()->findById($postId);
705
706
        if (!$this->zfcUserAuthentication()->hasIdentity()) {
707
            $response->setContent(\Zend\Json\Json::encode(array(
708
                'success' => 0
709
            )));
710
        } else {
711
            if ($request->isPost()) {
712
                if ($this->getGameService()->addComment(
713
                    $this->user,
714
                    $this->getRequest()->getServer('REMOTE_ADDR'),
715
                    $post,
716
                    $this->params()->fromPost('comment')
717
                )) {
718
                    $response->setContent(\Zend\Json\Json::encode(array(
719
                        'success' => 1
720
                    )));
721
                } else {
722
                    $response->setContent(\Zend\Json\Json::encode(array(
723
                        'success' => 0
724
                    )));
725
                }
726
            }
727
        }
728
729
        //ajax call ?
730
        if ($this->getRequest()->isXmlHttpRequest()) {
@@ 762-782 (lines=21) @@
759
            return $response;
760
        }
761
762
        if (!$this->zfcUserAuthentication()->hasIdentity()) {
763
            $response->setContent(\Zend\Json\Json::encode(array(
764
                'success' => 0
765
            )));
766
        } else {
767
            if ($request->isPost()) {
768
                if ($this->getGameService()->removeComment(
769
                    $this->user,
770
                    $this->getRequest()->getServer('REMOTE_ADDR'),
771
                    $commentId
772
                )) {
773
                    $response->setContent(\Zend\Json\Json::encode(array(
774
                        'success' => 1
775
                    )));
776
                } else {
777
                    $response->setContent(\Zend\Json\Json::encode(array(
778
                        'success' => 0
779
                    )));
780
                }
781
            }
782
        }
783
784
        return $response;
785
    }