Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

@@ 1131-1154 (lines=24) @@
1128
        $mailService->send($message);
1129
    }
1130
1131
    public function postFbWall($secretKey, $game, $user, $entry)
1132
    {
1133
        $topic = $game->getTitle();
1134
        
1135
        $shares = json_decode($entry->getSocialShares(), true);
1136
        if (!isset($shares['fbwall'])) {
1137
            $shares['fbwall'] = 1;
1138
        } else {
1139
            $shares['fbwall'] += 1;
1140
        }
1141
        $sharesJson = json_encode($shares);
1142
        $entry->setSocialShares($sharesJson);
1143
        $entry = $this->getEntryMapper()->update($entry);
1144
        
1145
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1146
            'user' => $user,
1147
            'game' => $game,
1148
            'secretKey' => $secretKey,
1149
            'topic' => $topic,
1150
            'entry' => $entry
1151
        ));
1152
1153
        return true;
1154
    }
1155
1156
    public function postFbRequest($secretKey, $game, $user, $entry, $to)
1157
    {
@@ 1180-1203 (lines=24) @@
1177
        return true;
1178
    }
1179
1180
    public function postTwitter($secretKey, $game, $user, $entry)
1181
    {
1182
        $topic = $game->getTitle();
1183
1184
        $shares = json_decode($entry->getSocialShares(), true);
1185
        if (!isset($shares['fbrequest'])) {
1186
            $shares['tweet'] = 1;
1187
        } else {
1188
            $shares['tweet'] += 1;
1189
        }
1190
        $sharesJson = json_encode($shares);
1191
        $entry->setSocialShares($sharesJson);
1192
        $entry = $this->getEntryMapper()->update($entry);
1193
        
1194
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1195
            'user' => $user,
1196
            'game' => $game,
1197
            'secretKey' => $secretKey,
1198
            'topic' => $topic,
1199
            'entry' => $entry
1200
        ));
1201
1202
        return true;
1203
    }
1204
1205
    public function postGoogle($secretKey, $game, $user, $entry)
1206
    {
@@ 1205-1228 (lines=24) @@
1202
        return true;
1203
    }
1204
1205
    public function postGoogle($secretKey, $game, $user, $entry)
1206
    {
1207
        $topic = $game->getTitle();
1208
        
1209
        $shares = json_decode($entry->getSocialShares(), true);
1210
        if (!isset($shares['fbrequest'])) {
1211
            $shares['google'] = 1;
1212
        } else {
1213
            $shares['google'] += 1;
1214
        }
1215
        $sharesJson = json_encode($shares);
1216
        $entry->setSocialShares($sharesJson);
1217
        $entry = $this->getEntryMapper()->update($entry);
1218
1219
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1220
            'user' => $user,
1221
            'game' => $game,
1222
            'secretKey' => $secretKey,
1223
            'topic' => $topic,
1224
            'entry' => $entry
1225
        ));
1226
1227
        return true;
1228
    }
1229
1230
    /**
1231
     * Is it possible to trigger a bonus entry ?