Code Duplication    Length = 8-11 lines in 8 locations

src/Controller/Frontend/LotteryController.php 2 locations

@@ 63-71 (lines=9) @@
60
        $socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl);
61
62
        $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user);
63
        if (!$lastEntry) {
64
            return $this->redirect()->toUrl(
65
                $this->frontendUrl()->fromRoute(
66
                    'lottery',
67
                    array('id' => $this->game->getIdentifier()),
68
                    array('force_canonical' => true)
69
                )
70
            );
71
        }
72
73
        $form = $this->getServiceLocator()->get('playgroundgame_sharemail_form');
74
        $form->setAttribute('method', 'post');
@@ 21-31 (lines=11) @@
18
    public function playAction()
19
    {
20
        $entry = $this->getGameService()->play($this->game, $this->user);
21
        if (!$entry) {
22
            // the user has already taken part of this game and the participation limit has been reached
23
            $this->flashMessenger()->addMessage('Vous avez déjà participé');
24
25
            return $this->redirect()->toUrl(
26
                $this->frontendUrl()->fromRoute(
27
                    'lottery/result',
28
                    array('id' => $this->game->getIdentifier())
29
                ) .'?playLimitReached=1'
30
            );
31
        }
32
33
        // Every entry is eligible to draw
34
        $entry->setDrawable(true);

src/Controller/Frontend/MissionController.php 1 location

@@ 49-59 (lines=11) @@
46
    {
47
        $subGameIdentifier = $this->getEvent()->getRouteMatch()->getParam('gameId');
48
        $entry             = $this->getGameService()->play($this->game, $this->user);
49
        if (!$entry) {
50
          // the user has already taken part of this game and the participation limit has been reached
51
            $this->flashMessenger()->addMessage('You have already played');
52
53
            return $this->redirect()->toUrl(
54
                $this->frontendUrl()->fromRoute(
55
                    'mission/result',
56
                    array('id' => $this->game->getIdentifier())
57
                )
58
            );
59
        }
60
61
        if (!$subGameIdentifier) {
62
            $subGame = $this->game->getNextPlayableGame($entry);

src/Controller/Frontend/PostVoteController.php 2 locations

@@ 157-165 (lines=9) @@
154
    {
155
        $entry = $this->getGameService()->findLastActiveEntry($this->game, $this->user);
156
         
157
        if (!$entry) {
158
            // the user has already taken part of this game and the participation limit has been reached
159
            return $this->redirect()->toUrl(
160
                $this->frontendUrl()->fromRoute(
161
                    'postvote/'.$this->game->nextStep('preview'),
162
                    array('id' => $this->game->getIdentifier())
163
                )
164
            );
165
        }
166
167
        // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu.
168
        $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0));
@@ 229-236 (lines=8) @@
226
        // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu.
227
        $post = $this->getGameService()->getPostVotePostMapper()->findById($postId);
228
229
        if (! $post || $post->getStatus() === 9) {
230
            return $this->redirect()->toUrl(
231
                $this->frontendUrl()->fromRoute(
232
                    'postvote',
233
                    array('id' => $this->game->getIdentifier())
234
                )
235
            );
236
        }
237
238
        $formModeration = new Form();
239
        $formModeration->setAttribute('method', 'post');

src/Controller/Frontend/QuizController.php 2 locations

@@ 222-232 (lines=11) @@
219
                        }
220
                    }
221
                    $entry = $this->getGameService()->play($this->game, $this->user);
222
                    if (!$entry) {
223
                        // the user has already taken part to this game and the participation limit has been reached
224
                        $this->flashMessenger()->addMessage('Vous avez déjà participé!');
225
226
                        return $this->redirect()->toUrl(
227
                            $this->frontendUrl()->fromRoute(
228
                                $this->game->getClassType() . '/result',
229
                                array('id' => $this->game->getIdentifier())
230
                            )
231
                        );
232
                    }
233
                }
234
            }
235
@@ 284-292 (lines=9) @@
281
        $socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl);
282
283
        $lastEntry = $this->getGameService()->findLastEntry($this->game, $this->user);
284
        if (!$lastEntry) {
285
            return $this->redirect()->toUrl(
286
                $this->frontendUrl()->fromRoute(
287
                    'quiz',
288
                    array('id' => $this->game->getIdentifier()),
289
                    array('force_canonical' => true)
290
                )
291
            );
292
        }
293
294
        // je compte les bonnes réponses et le ratio
295
        $maxCorrectAnswers = $this->game->getMaxCorrectAnswers();

src/Controller/Frontend/InstantWinController.php 1 location

@@ 96-104 (lines=9) @@
93
        }
94
        $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user);
95
96
        if (!$lastEntry) {
97
            return $this->redirect()->toUrl(
98
                $this->frontendUrl()->fromRoute(
99
                    'instantwin',
100
                    array('id' => $this->game->getIdentifier(), ),
101
                    array('force_canonical' => true)
102
                )
103
            );
104
        }
105
        $winner = $lastEntry->getWinner();
106
        $occurrence = null;
107