Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

@@ 1351-1374 (lines=24) @@
1348
        $mailService->send($message);
1349
    }
1350
1351
    public function postFbWall($secretKey, $game, $user, $entry)
1352
    {
1353
        $topic = $game->getTitle();
1354
        
1355
        $shares = json_decode($entry->getSocialShares(), true);
1356
        if (!isset($shares['fbwall'])) {
1357
            $shares['fbwall'] = 1;
1358
        } else {
1359
            $shares['fbwall'] += 1;
1360
        }
1361
        $sharesJson = json_encode($shares);
1362
        $entry->setSocialShares($sharesJson);
1363
        $entry = $this->getEntryMapper()->update($entry);
1364
        
1365
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1366
            'user' => $user,
1367
            'game' => $game,
1368
            'secretKey' => $secretKey,
1369
            'topic' => $topic,
1370
            'entry' => $entry
1371
        ));
1372
1373
        return true;
1374
    }
1375
1376
    public function postFbRequest($secretKey, $game, $user, $entry, $to)
1377
    {
@@ 1400-1423 (lines=24) @@
1397
        return true;
1398
    }
1399
1400
    public function postTwitter($secretKey, $game, $user, $entry)
1401
    {
1402
        $topic = $game->getTitle();
1403
1404
        $shares = json_decode($entry->getSocialShares(), true);
1405
        if (!isset($shares['fbrequest'])) {
1406
            $shares['tweet'] = 1;
1407
        } else {
1408
            $shares['tweet'] += 1;
1409
        }
1410
        $sharesJson = json_encode($shares);
1411
        $entry->setSocialShares($sharesJson);
1412
        $entry = $this->getEntryMapper()->update($entry);
1413
        
1414
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1415
            'user' => $user,
1416
            'game' => $game,
1417
            'secretKey' => $secretKey,
1418
            'topic' => $topic,
1419
            'entry' => $entry
1420
        ));
1421
1422
        return true;
1423
    }
1424
1425
    public function postGoogle($secretKey, $game, $user, $entry)
1426
    {
@@ 1425-1448 (lines=24) @@
1422
        return true;
1423
    }
1424
1425
    public function postGoogle($secretKey, $game, $user, $entry)
1426
    {
1427
        $topic = $game->getTitle();
1428
        
1429
        $shares = json_decode($entry->getSocialShares(), true);
1430
        if (!isset($shares['fbrequest'])) {
1431
            $shares['google'] = 1;
1432
        } else {
1433
            $shares['google'] += 1;
1434
        }
1435
        $sharesJson = json_encode($shares);
1436
        $entry->setSocialShares($sharesJson);
1437
        $entry = $this->getEntryMapper()->update($entry);
1438
1439
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1440
            'user' => $user,
1441
            'game' => $game,
1442
            'secretKey' => $secretKey,
1443
            'topic' => $topic,
1444
            'entry' => $entry
1445
        ));
1446
1447
        return true;
1448
    }
1449
1450
    /**
1451
     * Is it possible to trigger a bonus entry ?