Completed
Pull Request — master (#25)
by Fèvre
05:23 queued 02:34
created

CommentGate   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isFlooding() 0 10 1
1
<?php
2
namespace Xetaravel\Models\Gates;
3
4
use Carbon\Carbon;
5
use Xetaravel\Models\User;
6
use Xetaravel\Models\Comment;
7
8
trait CommentGate
9
{
10
    /**
11
     * Check whatever the user is flooding or not. (We check for all articles)
12
     *
13
     * @param \Xetaravel\Models\User $user The user to check.
14
     *
15
     * @return bool
16
     */
17
    public static function isFlooding(User $user): bool
18
    {
19
        return Comment::where('user_id', $user->id)
20
            ->where(
21
                'created_at',
22
                '>=',
23
                Carbon::now()->subSeconds(config('xetaravel.flood.blog.comment'))
24
            )
25
            ->exists();
26
    }
27
}
28