Code Duplication    Length = 21-22 lines in 4 locations

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

@@ 326-347 (lines=22) @@
323
        return $viewModel;
324
    }
325
326
    public function fbshareAction()
327
    {
328
        $result = parent::fbshareAction();
329
        $bonusEntry = false;
330
331
        if ($result->getVariable('success')) {
332
            $user = $this->zfcUserAuthentication()->getIdentity();
333
            // Improve this thing
334
            $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $user);
335
            if ($lastEntry && $lastEntry->getWinner()) {
336
                $bonusEntry = $this->getGameService()->addAnotherChance($this->game, $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 fbrequestAction()
350
    {
@@ 349-369 (lines=21) @@
346
        return $response;
347
    }
348
349
    public function fbrequestAction()
350
    {
351
        $result = parent::fbrequestAction();
352
        $bonusEntry = false;
353
354
        if ($result->getVariable('success')) {
355
            $user = $this->zfcUserAuthentication()->getIdentity();
356
            $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $user);
357
            if ($lastEntry && $lastEntry->getWinner()) {
358
                $bonusEntry = $this->getGameService()->addAnotherChance($this->game, $user, 1);
359
            }
360
        }
361
362
        $response = $this->getResponse();
363
        $response->setContent(\Zend\Json\Json::encode(array(
364
            'success' => $result,
365
            'playBonus' => $bonusEntry
366
        )));
367
368
        return $response;
369
    }
370
371
    public function tweetAction()
372
    {
@@ 371-391 (lines=21) @@
368
        return $response;
369
    }
370
371
    public function tweetAction()
372
    {
373
        $result = parent::tweetAction();
374
        $bonusEntry = false;
375
376
        if ($result->getVariable('success')) {
377
            $user = $this->zfcUserAuthentication()->getIdentity();
378
            $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $user);
379
            if ($lastEntry && $lastEntry->getWinner()) {
380
                $bonusEntry = $this->getGameService()->addAnotherChance($this->game, $user, 1);
381
            }
382
        }
383
384
        $response = $this->getResponse();
385
        $response->setContent(\Zend\Json\Json::encode(array(
386
            'success' => $result,
387
            'playBonus' => $bonusEntry
388
        )));
389
390
        return $response;
391
    }
392
393
    public function googleAction()
394
    {
@@ 393-413 (lines=21) @@
390
        return $response;
391
    }
392
393
    public function googleAction()
394
    {
395
        $result = parent::googleAction();
396
        $bonusEntry = false;
397
398
        if ($result->getVariable('success')) {
399
            $user = $this->zfcUserAuthentication()->getIdentity();
400
            $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $user);
401
            if ($lastEntry && $lastEntry->getWinner()) {
402
                $bonusEntry = $this->getGameService()->addAnotherChance($this->game, $user, 1);
403
            }
404
        }
405
406
        $response = $this->getResponse();
407
        $response->setContent(\Zend\Json\Json::encode(array(
408
            'success' => $result,
409
            'playBonus' => $bonusEntry
410
        )));
411
412
        return $response;
413
    }
414
415
    public function getGameService()
416
    {