Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

@@ 1033-1056 (lines=24) @@
1030
        $mailService->send($message);
1031
    }
1032
1033
    public function postFbWall($secretKey, $game, $user, $entry)
1034
    {
1035
        $topic = $game->getTitle();
1036
        
1037
        $shares = json_decode($entry->getSocialShares(), true);
1038
        if (!isset($shares['fbwall'])) {
1039
            $shares['fbwall'] = 1;
1040
        } else {
1041
            $shares['fbwall'] += 1;
1042
        }
1043
        $sharesJson = json_encode($shares);
1044
        $entry->setSocialShares($sharesJson);
1045
        $entry = $this->getEntryMapper()->update($entry);
1046
        
1047
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1048
            'user' => $user,
1049
            'game' => $game,
1050
            'secretKey' => $secretKey,
1051
            'topic' => $topic,
1052
            'entry' => $entry
1053
        ));
1054
1055
        return true;
1056
    }
1057
1058
    public function postFbRequest($secretKey, $game, $user, $entry, $to)
1059
    {
@@ 1082-1105 (lines=24) @@
1079
        return true;
1080
    }
1081
1082
    public function postTwitter($secretKey, $game, $user, $entry)
1083
    {
1084
        $topic = $game->getTitle();
1085
1086
        $shares = json_decode($entry->getSocialShares(), true);
1087
        if (!isset($shares['fbrequest'])) {
1088
            $shares['tweet'] = 1;
1089
        } else {
1090
            $shares['tweet'] += 1;
1091
        }
1092
        $sharesJson = json_encode($shares);
1093
        $entry->setSocialShares($sharesJson);
1094
        $entry = $this->getEntryMapper()->update($entry);
1095
        
1096
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1097
            'user' => $user,
1098
            'game' => $game,
1099
            'secretKey' => $secretKey,
1100
            'topic' => $topic,
1101
            'entry' => $entry
1102
        ));
1103
1104
        return true;
1105
    }
1106
1107
    public function postGoogle($secretKey, $game, $user, $entry)
1108
    {
@@ 1107-1130 (lines=24) @@
1104
        return true;
1105
    }
1106
1107
    public function postGoogle($secretKey, $game, $user, $entry)
1108
    {
1109
        $topic = $game->getTitle();
1110
        
1111
        $shares = json_decode($entry->getSocialShares(), true);
1112
        if (!isset($shares['fbrequest'])) {
1113
            $shares['google'] = 1;
1114
        } else {
1115
            $shares['google'] += 1;
1116
        }
1117
        $sharesJson = json_encode($shares);
1118
        $entry->setSocialShares($sharesJson);
1119
        $entry = $this->getEntryMapper()->update($entry);
1120
1121
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1122
            'user' => $user,
1123
            'game' => $game,
1124
            'secretKey' => $secretKey,
1125
            'topic' => $topic,
1126
            'entry' => $entry
1127
        ));
1128
1129
        return true;
1130
    }
1131
1132
    /**
1133
     * Is it possible to trigger a bonus entry ?