Passed
Push — main ( 51da02...cc341e )
by Usama
03:58
created

HasCommentBan::isCommentBanned()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 3
c 1
b 0
f 1
nc 3
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Usamamuneerchaudhary\Commentify\Traits;
4
5
use Carbon\Carbon;
6
7
trait HasCommentBan
8
{
9
    /**
10
     * Check if the user is banned from commenting.
11
     *
12
     * @return bool
13
     */
14
    public function isCommentBanned(): bool
15
    {
16
        if (!isset($this->comment_banned_until)) {
17
            return false;
18
        }
19
        return $this->comment_banned_until && Carbon::parse($this->comment_banned_until)->isFuture();
20
    }
21
}
22