Code Duplication    Length = 20-21 lines in 4 locations

src/PlaygroundGame/Controller/Frontend/QuizController.php 4 locations

@@ 306-326 (lines=21) @@
303
        return $viewModel;
304
    }
305
306
    public function fbshareAction()
307
    {
308
        $result = parent::fbshareAction();
309
        $bonusEntry = false;
310
311
        if ($result->getVariable('success')) {
312
            // Improve this thing
313
            $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user);
314
            if ($lastEntry && $lastEntry->getWinner()) {
315
                $bonusEntry = $this->getGameService()->addAnotherChance($this->game, $this->user, 1);
316
            }
317
        }
318
319
        $response = $this->getResponse();
320
        $response->setContent(\Zend\Json\Json::encode(array(
321
                'success' => $result,
322
                'playBonus' => $bonusEntry
323
        )));
324
325
        return $response;
326
    }
327
328
    public function fbrequestAction()
329
    {
@@ 328-347 (lines=20) @@
325
        return $response;
326
    }
327
328
    public function fbrequestAction()
329
    {
330
        $result = parent::fbrequestAction();
331
        $bonusEntry = false;
332
333
        if ($result->getVariable('success')) {
334
            $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user);
335
            if ($lastEntry && $lastEntry->getWinner()) {
336
                $bonusEntry = $this->getGameService()->addAnotherChance($this->game, $this->user, 1);
337
            }
338
        }
339
340
        $response = $this->getResponse();
341
        $response->setContent(\Zend\Json\Json::encode(array(
342
            'success' => $result,
343
            'playBonus' => $bonusEntry
344
        )));
345
346
        return $response;
347
    }
348
349
    public function tweetAction()
350
    {
@@ 349-368 (lines=20) @@
346
        return $response;
347
    }
348
349
    public function tweetAction()
350
    {
351
        $result = parent::tweetAction();
352
        $bonusEntry = false;
353
354
        if ($result->getVariable('success')) {
355
            $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user);
356
            if ($lastEntry && $lastEntry->getWinner()) {
357
                $bonusEntry = $this->getGameService()->addAnotherChance($this->game, $this->user, 1);
358
            }
359
        }
360
361
        $response = $this->getResponse();
362
        $response->setContent(\Zend\Json\Json::encode(array(
363
            'success' => $result,
364
            'playBonus' => $bonusEntry
365
        )));
366
367
        return $response;
368
    }
369
370
    public function googleAction()
371
    {
@@ 370-389 (lines=20) @@
367
        return $response;
368
    }
369
370
    public function googleAction()
371
    {
372
        $result = parent::googleAction();
373
        $bonusEntry = false;
374
375
        if ($result->getVariable('success')) {
376
            $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user);
377
            if ($lastEntry && $lastEntry->getWinner()) {
378
                $bonusEntry = $this->getGameService()->addAnotherChance($this->game, $this->user, 1);
379
            }
380
        }
381
382
        $response = $this->getResponse();
383
        $response->setContent(\Zend\Json\Json::encode(array(
384
            'success' => $result,
385
            'playBonus' => $bonusEntry
386
        )));
387
388
        return $response;
389
    }
390
391
    public function getGameService()
392
    {