TopicPolicy   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A show_draft() 0 4 2
A update() 0 4 2
A delete() 0 4 2
A recommend() 0 4 1
A wiki() 0 4 1
A pin() 0 4 1
A sink() 0 4 1
A append() 0 4 2
1
<?php
2
3
namespace Transmissor\Policies;
4
5
use Illuminate\Auth\Access\HandlesAuthorization;
6
use App\Models\User;
7
use App\Models\Topic;
8
9
class TopicPolicy
10
{
11
    use HandlesAuthorization;
12
13
    public function show_draft(User $user, Topic $topic)
14
    {
15
        return $user->may('manage_topics') || $topic->user_id == $user->id;
16
    }
17
18
    public function update(User $user, Topic $topic)
19
    {
20
        return $user->may('manage_topics') || $topic->user_id == $user->id;
21
    }
22
23
    public function delete(User $user, Topic $topic)
24
    {
25
        return $user->may('manage_topics') || $topic->user_id == $user->id;
26
    }
27
28
    public function recommend(User $user, Topic $topic)
0 ignored issues
show
Unused Code introduced by
The parameter $topic is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
    {
30
        return $user->may('manage_topics');
31
    }
32
33
    public function wiki(User $user, Topic $topic)
0 ignored issues
show
Unused Code introduced by
The parameter $topic is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        return $user->may('manage_topics');
36
    }
37
38
    public function pin(User $user, Topic $topic)
0 ignored issues
show
Unused Code introduced by
The parameter $topic is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
    {
40
        return $user->may('manage_topics');
41
    }
42
43
    public function sink(User $user, Topic $topic)
0 ignored issues
show
Unused Code introduced by
The parameter $topic is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45
        return $user->may('manage_topics');
46
    }
47
48
    public function append(User $user, Topic $topic)
49
    {
50
        return $user->may('manage_topics') || $topic->user_id == $user->id;
51
    }
52
}
53