Passed
Push — develop ( 6dcea6...5ae9a6 )
by Septianata
16:24
created

RolePolicy   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Test Coverage

Coverage 16.66%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 11
c 1
b 0
f 0
dl 0
loc 98
ccs 3
cts 18
cp 0.1666
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A view() 0 3 1
A update() 0 3 1
A create() 0 3 1
A delete() 0 3 1
A forceDelete() 0 3 1
A before() 0 4 2
A restore() 0 3 1
A viewAny() 0 3 1
1
<?php
2
3
namespace App\Policies;
4
5
use App\Models\Role;
6
use App\Models\User;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9
class RolePolicy
10
{
11
    use HandlesAuthorization;
12
13
    /**
14
     * Perform pre-authorization checks.
15
     *
16
     * @param  \App\Models\User  $user
17
     * @param  string  $ability
18
     * @return void|bool
19
     */
20 24
    public function before(User $user, $ability)
0 ignored issues
show
Unused Code introduced by
The parameter $ability is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

20
    public function before(User $user, /** @scrutinizer ignore-unused */ $ability)

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

Loading history...
21
    {
22 24
        if ($user->hasRole(Role::ROLE_ADMIN)) {
23 24
            return true;
24
        }
25
    }
26
27
    /**
28
     * Determine whether the user can view any models.
29
     *
30
     * @param  \App\Models\User  $user
31
     * @return \Illuminate\Auth\Access\Response|bool
32
     */
33
    public function viewAny(User $user)
34
    {
35
        return $user->hasRole(Role::ROLE_STAFF);
36
    }
37
38
    /**
39
     * Determine whether the user can view the model.
40
     *
41
     * @param  \App\Models\User  $user
42
     * @param  \App\Models\Role  $role
43
     * @return \Illuminate\Auth\Access\Response|bool
44
     */
45
    public function view(User $user, Role $role)
0 ignored issues
show
Unused Code introduced by
The parameter $role is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

45
    public function view(User $user, /** @scrutinizer ignore-unused */ Role $role)

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

Loading history...
46
    {
47
        return $user->hasRole(Role::ROLE_STAFF);
48
    }
49
50
    /**
51
     * Determine whether the user can create models.
52
     *
53
     * @param  \App\Models\User  $user
54
     * @return \Illuminate\Auth\Access\Response|bool
55
     */
56
    public function create(User $user)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

56
    public function create(/** @scrutinizer ignore-unused */ User $user)

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

Loading history...
57
    {
58
        return false;
59
    }
60
61
    /**
62
     * Determine whether the user can update the model.
63
     *
64
     * @param  \App\Models\User  $user
65
     * @param  \App\Models\Role  $role
66
     * @return \Illuminate\Auth\Access\Response|bool
67
     */
68
    public function update(User $user, Role $role)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

68
    public function update(/** @scrutinizer ignore-unused */ User $user, Role $role)

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

Loading history...
Unused Code introduced by
The parameter $role is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

68
    public function update(User $user, /** @scrutinizer ignore-unused */ Role $role)

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

Loading history...
69
    {
70
        return false;
71
    }
72
73
    /**
74
     * Determine whether the user can delete the model.
75
     *
76
     * @param  \App\Models\User  $user
77
     * @param  \App\Models\Role  $role
78
     * @return \Illuminate\Auth\Access\Response|bool
79
     */
80
    public function delete(User $user, Role $role)
0 ignored issues
show
Unused Code introduced by
The parameter $role is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

80
    public function delete(User $user, /** @scrutinizer ignore-unused */ Role $role)

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

Loading history...
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

80
    public function delete(/** @scrutinizer ignore-unused */ User $user, Role $role)

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

Loading history...
81
    {
82
        return false;
83
    }
84
85
    /**
86
     * Determine whether the user can restore the model.
87
     *
88
     * @param  \App\Models\User  $user
89
     * @param  \App\Models\Role  $role
90
     * @return \Illuminate\Auth\Access\Response|bool
91
     */
92
    public function restore(User $user, Role $role)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

92
    public function restore(/** @scrutinizer ignore-unused */ User $user, Role $role)

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

Loading history...
Unused Code introduced by
The parameter $role is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

92
    public function restore(User $user, /** @scrutinizer ignore-unused */ Role $role)

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

Loading history...
93
    {
94
        return false;
95
    }
96
97
    /**
98
     * Determine whether the user can permanently delete the model.
99
     *
100
     * @param  \App\Models\User  $user
101
     * @param  \App\Models\Role  $role
102
     * @return \Illuminate\Auth\Access\Response|bool
103
     */
104
    public function forceDelete(User $user, Role $role)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

104
    public function forceDelete(/** @scrutinizer ignore-unused */ User $user, Role $role)

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

Loading history...
Unused Code introduced by
The parameter $role is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

104
    public function forceDelete(User $user, /** @scrutinizer ignore-unused */ Role $role)

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

Loading history...
105
    {
106
        return false;
107
    }
108
}
109