Passed
Push — master ( 3b518a...cd2a02 )
by Adam
11:23
created

CommentPolicy   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 12
rs 10
c 1
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 3 3
A delete() 0 3 2
1
<?php
2
3
namespace Coyote\Policies;
4
5
use Coyote\Comment;
6
use Coyote\User;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9
class CommentPolicy
10
{
11
    use HandlesAuthorization;
12
13
    public function update(User $user, Comment $comment): bool
14
    {
15
        return !$comment->exists || $user->id === $comment->user_id || $user->can('comment-update');
16
    }
17
18
    public function delete(User $user, Comment $comment): bool
19
    {
20
        return $user->id === $comment->user_id || $user->can('comment-delete');
21
    }
22
}
23