Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

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