Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

@@ 1053-1076 (lines=24) @@
1050
        $mailService->send($message);
1051
    }
1052
1053
    public function postFbWall($secretKey, $game, $user, $entry)
1054
    {
1055
        $topic = $game->getTitle();
1056
        
1057
        $shares = json_decode($entry->getSocialShares(), true);
1058
        if (!isset($shares['fbwall'])) {
1059
            $shares['fbwall'] = 1;
1060
        } else {
1061
            $shares['fbwall'] += 1;
1062
        }
1063
        $sharesJson = json_encode($shares);
1064
        $entry->setSocialShares($sharesJson);
1065
        $entry = $this->getEntryMapper()->update($entry);
1066
        
1067
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1068
            'user' => $user,
1069
            'game' => $game,
1070
            'secretKey' => $secretKey,
1071
            'topic' => $topic,
1072
            'entry' => $entry
1073
        ));
1074
1075
        return true;
1076
    }
1077
1078
    public function postFbRequest($secretKey, $game, $user, $entry, $to)
1079
    {
@@ 1102-1125 (lines=24) @@
1099
        return true;
1100
    }
1101
1102
    public function postTwitter($secretKey, $game, $user, $entry)
1103
    {
1104
        $topic = $game->getTitle();
1105
1106
        $shares = json_decode($entry->getSocialShares(), true);
1107
        if (!isset($shares['fbrequest'])) {
1108
            $shares['tweet'] = 1;
1109
        } else {
1110
            $shares['tweet'] += 1;
1111
        }
1112
        $sharesJson = json_encode($shares);
1113
        $entry->setSocialShares($sharesJson);
1114
        $entry = $this->getEntryMapper()->update($entry);
1115
        
1116
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1117
            'user' => $user,
1118
            'game' => $game,
1119
            'secretKey' => $secretKey,
1120
            'topic' => $topic,
1121
            'entry' => $entry
1122
        ));
1123
1124
        return true;
1125
    }
1126
1127
    public function postGoogle($secretKey, $game, $user, $entry)
1128
    {
@@ 1127-1150 (lines=24) @@
1124
        return true;
1125
    }
1126
1127
    public function postGoogle($secretKey, $game, $user, $entry)
1128
    {
1129
        $topic = $game->getTitle();
1130
        
1131
        $shares = json_decode($entry->getSocialShares(), true);
1132
        if (!isset($shares['fbrequest'])) {
1133
            $shares['google'] = 1;
1134
        } else {
1135
            $shares['google'] += 1;
1136
        }
1137
        $sharesJson = json_encode($shares);
1138
        $entry->setSocialShares($sharesJson);
1139
        $entry = $this->getEntryMapper()->update($entry);
1140
1141
        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array(
1142
            'user' => $user,
1143
            'game' => $game,
1144
            'secretKey' => $secretKey,
1145
            'topic' => $topic,
1146
            'entry' => $entry
1147
        ));
1148
1149
        return true;
1150
    }
1151
1152
    /**
1153
     * Is it possible to trigger a bonus entry ?