Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

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