UserPolicy   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 91
rs 10
c 0
b 0
f 0
wmc 9

8 Methods

Rating   Name   Duplication   Size   Complexity  
A before() 0 4 2
A update() 0 3 1
A create() 0 3 1
A view() 0 3 1
A forceDelete() 0 3 1
A restore() 0 3 1
A delete() 0 3 1
A viewAny() 0 3 1
1
<?php
2
3
namespace Pratiksh\Adminetic\Policies;
4
5
use App\Models\User;
0 ignored issues
show
Bug introduced by
The type App\Models\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Auth\Access\HandlesAuthorization;
7
8
class UserPolicy
9
{
10
    use HandlesAuthorization;
11
12
    public function before($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

12
    public function before($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...
13
    {
14
        if ($user->isSuperAdmin()) {
15
            return true;
16
        }
17
    }
18
19
    /**
20
     * Determine whether the user can view any models.
21
     *
22
     * @param  \App\Models\User  $user
23
     * @return mixed
24
     */
25
    public function viewAny(User $user)
26
    {
27
        return $user->userCanDo('User', 'browse');
28
    }
29
30
    /**
31
     * Determine whether the user can view the model.
32
     *
33
     * @param  \App\Models\User  $user
34
     * @param  \App\Models\User  $model
35
     * @return mixed
36
     */
37
    public function view(User $user, User $model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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

37
    public function view(User $user, /** @scrutinizer ignore-unused */ User $model)

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...
38
    {
39
        return $user->userCanDo('User', 'read');
40
    }
41
42
    /**
43
     * Determine whether the user can create models.
44
     *
45
     * @param  \App\Models\User  $user
46
     * @return mixed
47
     */
48
    public function create(User $user)
49
    {
50
        return $user->userCanDo('User', 'add');
51
    }
52
53
    /**
54
     * Determine whether the user can update the model.
55
     *
56
     * @param  \App\Models\User  $user
57
     * @param  \App\Models\User  $model
58
     * @return mixed
59
     */
60
    public function update(User $user, User $model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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

60
    public function update(User $user, /** @scrutinizer ignore-unused */ User $model)

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...
61
    {
62
        return $user->userCanDo('User', 'edit');
63
    }
64
65
    /**
66
     * Determine whether the user can delete the model.
67
     *
68
     * @param  \App\Models\User  $user
69
     * @param  \App\Models\User  $model
70
     * @return mixed
71
     */
72
    public function delete(User $user, User $model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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

72
    public function delete(User $user, /** @scrutinizer ignore-unused */ User $model)

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...
73
    {
74
        return $user->userCanDo('User', 'delete');
75
    }
76
77
    /**
78
     * Determine whether the user can restore the model.
79
     *
80
     * @param  \App\Models\User  $user
81
     * @param  \App\Models\User  $model
82
     * @return mixed
83
     */
84
    public function restore(User $user, User $model)
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

84
    public function restore(/** @scrutinizer ignore-unused */ User $user, User $model)

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 $model 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

84
    public function restore(User $user, /** @scrutinizer ignore-unused */ User $model)

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...
85
    {
86
        return true;
87
    }
88
89
    /**
90
     * Determine whether the user can permanently delete the model.
91
     *
92
     * @param  \App\Models\User  $user
93
     * @param  \App\Models\User  $model
94
     * @return mixed
95
     */
96
    public function forceDelete(User $user, User $model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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

96
    public function forceDelete(User $user, /** @scrutinizer ignore-unused */ User $model)

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

96
    public function forceDelete(/** @scrutinizer ignore-unused */ User $user, User $model)

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...
97
    {
98
        return true;
99
    }
100
}
101