Test Failed
Pull Request — master (#41)
by Marcel
03:40
created

CheckRateable::checkRateable()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 3
eloc 11
nc 2
nop 3
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