Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

@@ 1151-1174 (lines=24) @@
1148
        $mailService->send($message);
1149
    }
1150
1151
    public function postFbWall($secretKey, $game, $user, $entry)
1152
    {
1153
        $topic = $game->getTitle();
1154
        
1155
        $shares = json_decode($entry->getSocialShares(), true);
1156
        if (!isset($shares['fbwall'])) {
1157
            $shares['fbwall'] = 1;
1158
        } else {
1159
            $shares['fbwall'] += 1;
1160
        }
1161
        $sharesJson = json_encode($shares);
1162
        $entry->setSocialShares($sharesJson);
1163
        $entry = $this->getEntryMapper()->update($entry);
1164
        
1165
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1166
            'user' => $user,
1167
            'game' => $game,
1168
            'secretKey' => $secretKey,
1169
            'topic' => $topic,
1170
            'entry' => $entry
1171
        ));
1172
1173
        return true;
1174
    }
1175
1176
    public function postFbRequest($secretKey, $game, $user, $entry, $to)
1177
    {
@@ 1200-1223 (lines=24) @@
1197
        return true;
1198
    }
1199
1200
    public function postTwitter($secretKey, $game, $user, $entry)
1201
    {
1202
        $topic = $game->getTitle();
1203
1204
        $shares = json_decode($entry->getSocialShares(), true);
1205
        if (!isset($shares['fbrequest'])) {
1206
            $shares['tweet'] = 1;
1207
        } else {
1208
            $shares['tweet'] += 1;
1209
        }
1210
        $sharesJson = json_encode($shares);
1211
        $entry->setSocialShares($sharesJson);
1212
        $entry = $this->getEntryMapper()->update($entry);
1213
        
1214
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1215
            'user' => $user,
1216
            'game' => $game,
1217
            'secretKey' => $secretKey,
1218
            'topic' => $topic,
1219
            'entry' => $entry
1220
        ));
1221
1222
        return true;
1223
    }
1224
1225
    public function postGoogle($secretKey, $game, $user, $entry)
1226
    {
@@ 1225-1248 (lines=24) @@
1222
        return true;
1223
    }
1224
1225
    public function postGoogle($secretKey, $game, $user, $entry)
1226
    {
1227
        $topic = $game->getTitle();
1228
        
1229
        $shares = json_decode($entry->getSocialShares(), true);
1230
        if (!isset($shares['fbrequest'])) {
1231
            $shares['google'] = 1;
1232
        } else {
1233
            $shares['google'] += 1;
1234
        }
1235
        $sharesJson = json_encode($shares);
1236
        $entry->setSocialShares($sharesJson);
1237
        $entry = $this->getEntryMapper()->update($entry);
1238
1239
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1240
            'user' => $user,
1241
            'game' => $game,
1242
            'secretKey' => $secretKey,
1243
            'topic' => $topic,
1244
            'entry' => $entry
1245
        ));
1246
1247
        return true;
1248
    }
1249
1250
    /**
1251
     * Is it possible to trigger a bonus entry ?