Code Duplication    Length = 24-24 lines in 3 locations

src/Service/Game.php 3 locations

@@ 1308-1331 (lines=24) @@
1305
        $mailService->send($message);
1306
    }
1307
1308
    public function postFbWall($secretKey, $game, $user, $entry)
1309
    {
1310
        $topic = $game->getTitle();
1311
        
1312
        $shares = json_decode($entry->getSocialShares(), true);
1313
        if (!isset($shares['fbwall'])) {
1314
            $shares['fbwall'] = 1;
1315
        } else {
1316
            $shares['fbwall'] += 1;
1317
        }
1318
        $sharesJson = json_encode($shares);
1319
        $entry->setSocialShares($sharesJson);
1320
        $entry = $this->getEntryMapper()->update($entry);
1321
        
1322
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1323
            'user' => $user,
1324
            'game' => $game,
1325
            'secretKey' => $secretKey,
1326
            'topic' => $topic,
1327
            'entry' => $entry
1328
        ));
1329
1330
        return true;
1331
    }
1332
1333
    public function postFbRequest($secretKey, $game, $user, $entry, $to)
1334
    {
@@ 1357-1380 (lines=24) @@
1354
        return true;
1355
    }
1356
1357
    public function postTwitter($secretKey, $game, $user, $entry)
1358
    {
1359
        $topic = $game->getTitle();
1360
1361
        $shares = json_decode($entry->getSocialShares(), true);
1362
        if (!isset($shares['fbrequest'])) {
1363
            $shares['tweet'] = 1;
1364
        } else {
1365
            $shares['tweet'] += 1;
1366
        }
1367
        $sharesJson = json_encode($shares);
1368
        $entry->setSocialShares($sharesJson);
1369
        $entry = $this->getEntryMapper()->update($entry);
1370
        
1371
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1372
            'user' => $user,
1373
            'game' => $game,
1374
            'secretKey' => $secretKey,
1375
            'topic' => $topic,
1376
            'entry' => $entry
1377
        ));
1378
1379
        return true;
1380
    }
1381
1382
    public function postGoogle($secretKey, $game, $user, $entry)
1383
    {
@@ 1382-1405 (lines=24) @@
1379
        return true;
1380
    }
1381
1382
    public function postGoogle($secretKey, $game, $user, $entry)
1383
    {
1384
        $topic = $game->getTitle();
1385
        
1386
        $shares = json_decode($entry->getSocialShares(), true);
1387
        if (!isset($shares['fbrequest'])) {
1388
            $shares['google'] = 1;
1389
        } else {
1390
            $shares['google'] += 1;
1391
        }
1392
        $sharesJson = json_encode($shares);
1393
        $entry->setSocialShares($sharesJson);
1394
        $entry = $this->getEntryMapper()->update($entry);
1395
1396
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1397
            'user' => $user,
1398
            'game' => $game,
1399
            'secretKey' => $secretKey,
1400
            'topic' => $topic,
1401
            'entry' => $entry
1402
        ));
1403
1404
        return true;
1405
    }
1406
1407
    /**
1408
     * Is it possible to trigger a bonus entry ?