Completed
Pull Request — master (#133)
by
unknown
05:13
created

UserPolicy::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 2
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
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. ( Ignorable by Annotation )

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

18
    public function before(/** @scrutinizer ignore-unused */ $user, $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...
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

18
    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...
19
    {
20
        // TODO: Admins...
21
        // if ($user->isSuperAdmin()) {
22
        //     return true;
23
        // }
24
        return false;
25
    }
26
27
    /**
28
     * Determine whether the user can view the user.
29
     *
30
     * @param  \App\User  $user
31
     * @param  \App\User  $user
32
     * @return boolean
33
     */
34
    public function view(User $user, User $user2)
35
    {
36
        // TODO: Check if user role is > 0
37
        return $user->role > 1 || $user->id === $user2->id;
38
    }
39
40
    /**
41
     * Determine whether the user can create users.
42
     *
43
     * @param  \App\User  $user
44
     * @return boolean
45
     */
46
    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

46
    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...
47
    {
48
        // TODO: Check if user role > 1
49
        return true;
50
    }
51
52
    /**
53
     * Determine whether the user can update the user2.
54
     *
55
     * @param  \App\User  $user
56
     * @param  \App\User  $user
57
     * @return boolean
58
     */
59
    public function update(User $user, User $user2)
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

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

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

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

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...
60
    {
61
        // Users can update themselves
62
        //return $user->id === $user->id;
63
        return true;
64
    }
65
66
    /**
67
     * Determine whether the user can delete the user.
68
     *
69
     * @param  \App\User  $user
70
     * @param  \App\User  $user
71
     * @return boolean
72
     */
73
    public function delete(User $user, User $user2)
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

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

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

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

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...
74
    {
75
        // TODO: Check if user role > 1
76
        return true;
77
    }
78
}
79