Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

@@ 1361-1384 (lines=24) @@
1358
        $mailService->send($message);
1359
    }
1360
1361
    public function postFbWall($secretKey, $game, $user, $entry)
1362
    {
1363
        $topic = $game->getTitle();
1364
        
1365
        $shares = json_decode($entry->getSocialShares(), true);
1366
        if (!isset($shares['fbwall'])) {
1367
            $shares['fbwall'] = 1;
1368
        } else {
1369
            $shares['fbwall'] += 1;
1370
        }
1371
        $sharesJson = json_encode($shares);
1372
        $entry->setSocialShares($sharesJson);
1373
        $entry = $this->getEntryMapper()->update($entry);
1374
        
1375
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1376
            'user' => $user,
1377
            'game' => $game,
1378
            'secretKey' => $secretKey,
1379
            'topic' => $topic,
1380
            'entry' => $entry
1381
        ));
1382
1383
        return true;
1384
    }
1385
1386
    public function postFbRequest($secretKey, $game, $user, $entry, $to)
1387
    {
@@ 1410-1433 (lines=24) @@
1407
        return true;
1408
    }
1409
1410
    public function postTwitter($secretKey, $game, $user, $entry)
1411
    {
1412
        $topic = $game->getTitle();
1413
1414
        $shares = json_decode($entry->getSocialShares(), true);
1415
        if (!isset($shares['fbrequest'])) {
1416
            $shares['tweet'] = 1;
1417
        } else {
1418
            $shares['tweet'] += 1;
1419
        }
1420
        $sharesJson = json_encode($shares);
1421
        $entry->setSocialShares($sharesJson);
1422
        $entry = $this->getEntryMapper()->update($entry);
1423
        
1424
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1425
            'user' => $user,
1426
            'game' => $game,
1427
            'secretKey' => $secretKey,
1428
            'topic' => $topic,
1429
            'entry' => $entry
1430
        ));
1431
1432
        return true;
1433
    }
1434
1435
    public function postGoogle($secretKey, $game, $user, $entry)
1436
    {
@@ 1435-1458 (lines=24) @@
1432
        return true;
1433
    }
1434
1435
    public function postGoogle($secretKey, $game, $user, $entry)
1436
    {
1437
        $topic = $game->getTitle();
1438
        
1439
        $shares = json_decode($entry->getSocialShares(), true);
1440
        if (!isset($shares['fbrequest'])) {
1441
            $shares['google'] = 1;
1442
        } else {
1443
            $shares['google'] += 1;
1444
        }
1445
        $sharesJson = json_encode($shares);
1446
        $entry->setSocialShares($sharesJson);
1447
        $entry = $this->getEntryMapper()->update($entry);
1448
1449
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1450
            'user' => $user,
1451
            'game' => $game,
1452
            'secretKey' => $secretKey,
1453
            'topic' => $topic,
1454
            'entry' => $entry
1455
        ));
1456
1457
        return true;
1458
    }
1459
1460
    /**
1461
     * Is it possible to trigger a bonus entry ?