Code Duplication    Length = 24-24 lines in 3 locations

src/PlaygroundGame/Service/Game.php 3 locations

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