Code Duplication    Length = 20-21 lines in 4 locations

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

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