Code Duplication    Length = 3-4 lines in 11 locations

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

@@ 71-73 (lines=3) @@
68
        $socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl);
69
70
        $lastEntry = $sg->findLastInactiveEntry($game, $user);
71
        if (!$lastEntry) {
72
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('lottery', array('id' => $game->getIdentifier(), 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel')), array('force_canonical' => true)));
73
        }
74
75
        if (!$user && !$game->getAnonymousAllowed()) {
76
            $redirect = urlencode($this->frontendUrl()->fromRoute('lottery/result', array('id' => $game->getIdentifier(), 'channel' => $channel)));

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

@@ 52-54 (lines=3) @@
49
50
        if (!$entry) {
51
            $lastEntry = $sg->findLastInactiveEntry($game, $user);
52
            if ($lastEntry === null) {
53
                return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
54
            }
55
56
            $lastEntryId = $lastEntry->getId();
57
            $lastPost = $sg->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntryId));
@@ 71-73 (lines=3) @@
68
            }
69
        }
70
71
        if (! $game->getForm()) {
72
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
73
        }
74
75
        $form = $sg->createFormFromJson($game->getForm()->getForm(), 'postvoteForm');
76
@@ 149-152 (lines=4) @@
146
147
        $entry = $sg->findLastActiveEntry($game, $user);
148
         
149
        if (!$entry) {
150
            // the user has already taken part of this game and the participation limit has been reached
151
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote/'.$game->nextStep('preview'), array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
152
        }
153
154
        // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu.
155
        $post = $sg->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0));
@@ 157-159 (lines=3) @@
154
        // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu.
155
        $post = $sg->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0));
156
157
        if (! $post) {
158
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
159
        }
160
161
        if ($this->getRequest()->isPost()) {
162
            $post = $this->getGameService()->confirmPost($game, $user);
@@ 210-212 (lines=3) @@
207
        // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu.
208
        $post = $sg->getPostVotePostMapper()->findById($postId);
209
210
        if (! $post || $post->getStatus() === 9) {
211
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
212
        }
213
214
        $formModeration = new Form();
215
        $formModeration->setAttribute('method', 'post');
@@ 302-304 (lines=3) @@
299
        // Has the user finished the game ?
300
        $lastEntry = $this->getGameService()->findLastInactiveEntry($game, $user);
301
302
        if ($lastEntry === null) {
303
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
304
        }
305
306
        if (!$user && !$game->getAnonymousAllowed()) {
307
            $redirect = urlencode($this->frontendUrl()->fromRoute('postvote/result', array('id' => $game->getIdentifier(), 'channel' => $channel)));
@@ 328-330 (lines=3) @@
325
        // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu.
326
        $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntry));
327
328
        if (! $post) {
329
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
330
        }
331
332
        $viewModel = $this->buildView($game);
333
@@ 637-639 (lines=3) @@
634
        // Has the user finished the game ?
635
        $lastEntry = $this->getGameService()->findLastInactiveEntry($game, $user);
636
    
637
        if ($lastEntry === null) {
638
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
639
        }
640
    
641
        $post = $sg->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntry));
642
    

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

@@ 189-191 (lines=3) @@
186
        $socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl);
187
188
        $lastEntry = $sg->findLastInactiveEntry($game, $user);
189
        if (!$lastEntry) {
190
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('quiz', array('id' => $game->getIdentifier(), 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel')), array('force_canonical' => true)));
191
        }
192
193
        // je compte les bonnes réponses et le ratio
194
        $maxCorrectAnswers = $game->getMaxCorrectAnswers();

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

@@ 725-727 (lines=3) @@
722
        // Has the user finished the game ?
723
        $lastEntry = $this->getGameService()->findLastInactiveEntry($game, $user);
724
    
725
        if ($lastEntry === null) {
726
            return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier, 'channel' => $this->getEvent()->getRouteMatch()->getParam('channel'))));
727
        }
728
    
729
        if (!$user && !$game->getAnonymousAllowed()) {
730
            $redirect = urlencode($this->frontendUrl()->fromRoute('postvote/result', array('id' => $game->getIdentifier(), 'channel' => $channel)));