Code Duplication    Length = 14-15 lines in 6 locations

src/Mapper/Entry.php 6 locations

@@ 68-81 (lines=14) @@
65
     * @param unknown_type $game
66
     * @param unknown_type $user
67
     */
68
    public function findLastEntriesByUser($game, $user, $dateLimit)
69
    {
70
        $query = $this->em->createQuery(
71
            'SELECT e.id FROM PlaygroundGame\Entity\Entry e 
72
             WHERE e.user = :user AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date'
73
        );
74
        $query->setParameter('user', $user);
75
        $query->setParameter('game', $game);
76
        $query->setParameter('date', $dateLimit);
77
78
        $total = $query->getResult();
79
80
        return $total;
81
    }
82
    
83
    public function findLastEntriesByAnonymousIdentifier($game, $anonymousIdentifier, $dateLimit)
84
    {
@@ 83-97 (lines=15) @@
80
        return $total;
81
    }
82
    
83
    public function findLastEntriesByAnonymousIdentifier($game, $anonymousIdentifier, $dateLimit)
84
    {
85
        $query = $this->em->createQuery(
86
            'SELECT e.id FROM PlaygroundGame\Entity\Entry e 
87
             WHERE e.anonymousIdentifier = :anonymousIdentifier AND e.game = :game 
88
             AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date'
89
        );
90
        $query->setParameter('anonymousIdentifier', $anonymousIdentifier);
91
        $query->setParameter('game', $game);
92
        $query->setParameter('date', $dateLimit);
93
    
94
        $total = $query->getResult();
95
96
        return $total;
97
    }
98
99
    public function findLastEntriesByIp($game, $ip, $dateLimit)
100
    {
@@ 99-112 (lines=14) @@
96
        return $total;
97
    }
98
99
    public function findLastEntriesByIp($game, $ip, $dateLimit)
100
    {
101
        $query = $this->em->createQuery(
102
            'SELECT e.id FROM PlaygroundGame\Entity\Entry e 
103
             WHERE e.ip = :ip AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date'
104
        );
105
        $query->setParameter('ip', $ip);
106
        $query->setParameter('game', $game);
107
        $query->setParameter('date', $dateLimit);
108
    
109
        $total = $query->getResult();
110
    
111
        return $total;
112
    }
113
114
    /**
115
     * Get all the entries of the player except those offered as bonus
@@ 120-133 (lines=14) @@
117
     * @param unknown_type $game
118
     * @param unknown_type $user
119
     */
120
    public function countLastEntriesByUser($game, $user, $dateLimit)
121
    {
122
        $query = $this->em->createQuery(
123
            'SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e 
124
             WHERE e.user = :user AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date'
125
        );
126
        $query->setParameter('user', $user);
127
        $query->setParameter('game', $game);
128
        $query->setParameter('date', $dateLimit);
129
130
        $total = $query->getSingleScalarResult();
131
132
        return $total;
133
    }
134
    
135
    public function countLastEntriesByAnonymousIdentifier($game, $anonymousIdentifier, $dateLimit)
136
    {
@@ 135-149 (lines=15) @@
132
        return $total;
133
    }
134
    
135
    public function countLastEntriesByAnonymousIdentifier($game, $anonymousIdentifier, $dateLimit)
136
    {
137
        $query = $this->em->createQuery(
138
            'SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e 
139
             WHERE e.anonymousIdentifier = :anonymousIdentifier AND e.game = :game 
140
             AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date'
141
        );
142
        $query->setParameter('anonymousIdentifier', $anonymousIdentifier);
143
        $query->setParameter('game', $game);
144
        $query->setParameter('date', $dateLimit);
145
    
146
        $total = $query->getSingleScalarResult();
147
148
        return $total;
149
    }
150
151
    public function countLastEntriesByIp($game, $ip, $dateLimit)
152
    {
@@ 151-164 (lines=14) @@
148
        return $total;
149
    }
150
151
    public function countLastEntriesByIp($game, $ip, $dateLimit)
152
    {
153
        $query = $this->em->createQuery(
154
            'SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e 
155
             WHERE e.ip = :ip AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date'
156
        );
157
        $query->setParameter('ip', $ip);
158
        $query->setParameter('game', $game);
159
        $query->setParameter('date', $dateLimit);
160
    
161
        $total = $query->getSingleScalarResult();
162
    
163
        return $total;
164
    }
165
166
    /**
167
     * get users with only one participation able to