Completed
Push — master ( 885948...db2a72 )
by Brandon
02:49
created

UserPolicy   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 70
ccs 0
cts 10
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A before() 0 7 1
A view() 0 5 1
A create() 0 5 1
A update() 0 6 1
A delete() 0 5 1
1
<?php
2
3
namespace App\Policies;
4
5
use App\User;
6
use Illuminate\Auth\Access\HandlesAuthorization;
7
8
class UserPolicy
9
{
10
    use HandlesAuthorization;
11
12
    /**
13
     * The before method will be executed before any other methods on the policy,
14
     * giving you an opportunity to authorize the action before the intended
15
     * policy method is actually called. This feature is most commonly used for
16
     * authorizing application administrators to perform any action.
17
     */
18
    public function before($user, $ability)
0 ignored issues
show
Unused Code introduced by
The parameter $user 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...
Unused Code introduced by
The parameter $ability 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...
19
    {
20
        // TODO: Admins...
21
        // if ($user->isSuperAdmin()) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
22
        //     return true;
23
        // }
24
    }
25
26
    /**
27
     * Determine whether the user can view the user.
28
     *
29
     * @param  \App\User  $user
30
     * @param  \App\User  $user
31
     * @return mixed
32
     */
33
    public function view(User $user, User $user)
0 ignored issues
show
Bug introduced by
The parameter $user is used multiple times.
Loading history...
Unused Code introduced by
The parameter $user 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...
Coding Style introduced by
Variable "$user" appears more than once in function declaration
Loading history...
34
    {
35
        // TODO: Check if user role is > 0
36
        return true;
37
    }
38
39
    /**
40
     * Determine whether the user can create users.
41
     *
42
     * @param  \App\User  $user
43
     * @return mixed
44
     */
45
    public function create(User $user)
0 ignored issues
show
Unused Code introduced by
The parameter $user 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...
46
    {
47
        // TODO: Check if user role > 1
48
        return true;
49
    }
50
51
    /**
52
     * Determine whether the user can update the user.
53
     *
54
     * @param  \App\User  $user
55
     * @param  \App\User  $user
56
     * @return mixed
57
     */
58
    public function update(User $user, User $user)
0 ignored issues
show
Bug introduced by
The parameter $user is used multiple times.
Loading history...
Unused Code introduced by
The parameter $user 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...
Coding Style introduced by
Variable "$user" appears more than once in function declaration
Loading history...
59
    {
60
        // Users can update themselves
61
        //return $user->id === $user->id;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
62
        return true;
63
    }
64
65
    /**
66
     * Determine whether the user can delete the user.
67
     *
68
     * @param  \App\User  $user
69
     * @param  \App\User  $user
70
     * @return mixed
71
     */
72
    public function delete(User $user, User $user)
0 ignored issues
show
Bug introduced by
The parameter $user is used multiple times.
Loading history...
Unused Code introduced by
The parameter $user 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...
Coding Style introduced by
Variable "$user" appears more than once in function declaration
Loading history...
73
    {
74
        // TODO: Check if user role > 1
75
        return true;
76
    }
77
}
78