Code Duplication    Length = 11-14 lines in 4 locations

code/controllers/CommentingController.php 4 locations

@@ 230-243 (lines=14) @@
227
    /**
228
     * Deletes a given {@link Comment} via the URL.
229
     */
230
    public function delete()
231
    {
232
        $comment = $this->getComment();
233
        if (!$comment) {
234
            return $this->httpError(404);
235
        }
236
        if (!$comment->canDelete()) {
237
            return Security::permissionFailure($this, 'You do not have permission to delete this comment');
238
        }
239
        if (!$comment->getSecurityToken()->checkRequest($this->request)) {
240
            return $this->httpError(400);
241
        }
242
243
        $comment->delete();
244
245
        return $this->request->isAjax()
246
            ? true
@@ 253-263 (lines=11) @@
250
    /**
251
     * Marks a given {@link Comment} as spam. Removes the comment from display
252
     */
253
    public function spam()
254
    {
255
        $comment = $this->getComment();
256
        if (!$comment) {
257
            return $this->httpError(404);
258
        }
259
        if (!$comment->canEdit()) {
260
            return Security::permissionFailure($this, 'You do not have permission to edit this comment');
261
        }
262
        if (!$comment->getSecurityToken()->checkRequest($this->request)) {
263
            return $this->httpError(400);
264
        }
265
266
        $comment->markSpam();
@@ 273-283 (lines=11) @@
270
    /**
271
     * Marks a given {@link Comment} as ham (not spam).
272
     */
273
    public function ham()
274
    {
275
        $comment = $this->getComment();
276
        if (!$comment) {
277
            return $this->httpError(404);
278
        }
279
        if (!$comment->canEdit()) {
280
            return Security::permissionFailure($this, 'You do not have permission to edit this comment');
281
        }
282
        if (!$comment->getSecurityToken()->checkRequest($this->request)) {
283
            return $this->httpError(400);
284
        }
285
286
        $comment->markApproved();
@@ 293-303 (lines=11) @@
290
    /**
291
     * Marks a given {@link Comment} as approved.
292
     */
293
    public function approve()
294
    {
295
        $comment = $this->getComment();
296
        if (!$comment) {
297
            return $this->httpError(404);
298
        }
299
        if (!$comment->canEdit()) {
300
            return Security::permissionFailure($this, 'You do not have permission to approve this comment');
301
        }
302
        if (!$comment->getSecurityToken()->checkRequest($this->request)) {
303
            return $this->httpError(400);
304
        }
305
306
        $comment->markApproved();