Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

@@ 1238-1261 (lines=24) @@
1235
        $mailService->send($message);
1236
    }
1237
1238
    public function postFbWall($secretKey, $game, $user, $entry)
1239
    {
1240
        $topic = $game->getTitle();
1241
        
1242
        $shares = json_decode($entry->getSocialShares(), true);
1243
        if (!isset($shares['fbwall'])) {
1244
            $shares['fbwall'] = 1;
1245
        } else {
1246
            $shares['fbwall'] += 1;
1247
        }
1248
        $sharesJson = json_encode($shares);
1249
        $entry->setSocialShares($sharesJson);
1250
        $entry = $this->getEntryMapper()->update($entry);
1251
        
1252
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1253
            'user' => $user,
1254
            'game' => $game,
1255
            'secretKey' => $secretKey,
1256
            'topic' => $topic,
1257
            'entry' => $entry
1258
        ));
1259
1260
        return true;
1261
    }
1262
1263
    public function postFbRequest($secretKey, $game, $user, $entry, $to)
1264
    {
@@ 1287-1310 (lines=24) @@
1284
        return true;
1285
    }
1286
1287
    public function postTwitter($secretKey, $game, $user, $entry)
1288
    {
1289
        $topic = $game->getTitle();
1290
1291
        $shares = json_decode($entry->getSocialShares(), true);
1292
        if (!isset($shares['fbrequest'])) {
1293
            $shares['tweet'] = 1;
1294
        } else {
1295
            $shares['tweet'] += 1;
1296
        }
1297
        $sharesJson = json_encode($shares);
1298
        $entry->setSocialShares($sharesJson);
1299
        $entry = $this->getEntryMapper()->update($entry);
1300
        
1301
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1302
            'user' => $user,
1303
            'game' => $game,
1304
            'secretKey' => $secretKey,
1305
            'topic' => $topic,
1306
            'entry' => $entry
1307
        ));
1308
1309
        return true;
1310
    }
1311
1312
    public function postGoogle($secretKey, $game, $user, $entry)
1313
    {
@@ 1312-1335 (lines=24) @@
1309
        return true;
1310
    }
1311
1312
    public function postGoogle($secretKey, $game, $user, $entry)
1313
    {
1314
        $topic = $game->getTitle();
1315
        
1316
        $shares = json_decode($entry->getSocialShares(), true);
1317
        if (!isset($shares['fbrequest'])) {
1318
            $shares['google'] = 1;
1319
        } else {
1320
            $shares['google'] += 1;
1321
        }
1322
        $sharesJson = json_encode($shares);
1323
        $entry->setSocialShares($sharesJson);
1324
        $entry = $this->getEntryMapper()->update($entry);
1325
1326
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1327
            'user' => $user,
1328
            'game' => $game,
1329
            'secretKey' => $secretKey,
1330
            'topic' => $topic,
1331
            'entry' => $entry
1332
        ));
1333
1334
        return true;
1335
    }
1336
1337
    /**
1338
     * Is it possible to trigger a bonus entry ?