CheckRateableHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A checkRateable() 0 15 3
1
<?php
2
3
/*
4
 * rmarchiv.tk
5
 * (c) 2016-2017 by Marcel 'ryg' Hering
6
 */
7
8
namespace App\Helpers;
9
10
class CheckRateableHelper
11
{
12
    public static function checkRateable($content_type, $content_id, $user_id)
13
    {
14
        $comments = \DB::table('comments')
15
            ->selectRaw('SUM(comments.vote_up) as up, SUM(comments.vote_down) as down')
16
            ->where('comments.content_id', '=', $content_id)
17
            ->where('comments.content_type', '=', $content_type)
18
            ->where('comments.user_id', '=', $user_id)
19
            ->first();
20
21
        if ($comments->up > 0 || $comments->down > 0) {
22
            return false;
23
        } else {
24
            return true;
25
        }
26
    }
27
}
28