Test Failed
Push — master ( d4bdb3...458817 )
by Marcel
01:05
created

CheckRateable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 0
dl 0
loc 16
rs 10
1
<?php
2
3
namespace App\Helpers;
4
5
class CheckRateableHelper
6
{
7
    public static function checkRateable($content_type, $content_id, $user_id)
8
    {
9
        $comments = \DB::table('comments')
10
            ->selectRaw('SUM(comments.vote_up) as up, SUM(comments.vote_down) as down')
11
            ->where('comments.content_id', '=', $content_id)
12
            ->where('comments.content_type', '=', $content_type)
13
            ->where('comments.user_id', '=', $user_id)
14
            ->first();
15
16
        if ($comments->up > 0 || $comments->down > 0) {
17
            return false;
18
        } else {
19
            return true;
20
        }
21
    }
22
}
23