Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

@@ 1336-1359 (lines=24) @@
1333
        $mailService->send($message);
1334
    }
1335
1336
    public function postFbWall($secretKey, $game, $user, $entry)
1337
    {
1338
        $topic = $game->getTitle();
1339
        
1340
        $shares = json_decode($entry->getSocialShares(), true);
1341
        if (!isset($shares['fbwall'])) {
1342
            $shares['fbwall'] = 1;
1343
        } else {
1344
            $shares['fbwall'] += 1;
1345
        }
1346
        $sharesJson = json_encode($shares);
1347
        $entry->setSocialShares($sharesJson);
1348
        $entry = $this->getEntryMapper()->update($entry);
1349
        
1350
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1351
            'user' => $user,
1352
            'game' => $game,
1353
            'secretKey' => $secretKey,
1354
            'topic' => $topic,
1355
            'entry' => $entry
1356
        ));
1357
1358
        return true;
1359
    }
1360
1361
    public function postFbRequest($secretKey, $game, $user, $entry, $to)
1362
    {
@@ 1385-1408 (lines=24) @@
1382
        return true;
1383
    }
1384
1385
    public function postTwitter($secretKey, $game, $user, $entry)
1386
    {
1387
        $topic = $game->getTitle();
1388
1389
        $shares = json_decode($entry->getSocialShares(), true);
1390
        if (!isset($shares['fbrequest'])) {
1391
            $shares['tweet'] = 1;
1392
        } else {
1393
            $shares['tweet'] += 1;
1394
        }
1395
        $sharesJson = json_encode($shares);
1396
        $entry->setSocialShares($sharesJson);
1397
        $entry = $this->getEntryMapper()->update($entry);
1398
        
1399
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1400
            'user' => $user,
1401
            'game' => $game,
1402
            'secretKey' => $secretKey,
1403
            'topic' => $topic,
1404
            'entry' => $entry
1405
        ));
1406
1407
        return true;
1408
    }
1409
1410
    public function postGoogle($secretKey, $game, $user, $entry)
1411
    {
@@ 1410-1433 (lines=24) @@
1407
        return true;
1408
    }
1409
1410
    public function postGoogle($secretKey, $game, $user, $entry)
1411
    {
1412
        $topic = $game->getTitle();
1413
        
1414
        $shares = json_decode($entry->getSocialShares(), true);
1415
        if (!isset($shares['fbrequest'])) {
1416
            $shares['google'] = 1;
1417
        } else {
1418
            $shares['google'] += 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
    /**
1436
     * Is it possible to trigger a bonus entry ?