Passed
Pull Request — master (#53)
by
unknown
05:24
created

TournamentPolicy   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 47
ccs 6
cts 14
cp 0.4286
rs 10
c 0
b 0
f 0
wmc 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A before() 0 6 2
A edit() 0 3 2
A store() 0 3 1
A update() 0 3 2
A destroy() 0 3 2
A create() 0 4 1
1
<?php
2
3
namespace App\Policies;
4
5
//use Illuminate\Auth\Access\HandlesAuthorization;
6
7
use App\Tournament;
8
use App\User;
9
use Illuminate\Auth\Access\HandlesAuthorization;
10
11
class TournamentPolicy
12
{
13
    use HandlesAuthorization;
14
15
    /**
16
     * Create a new policy instance.
17
     * @param User $user
18
     * @param $ability
19
     * @return bool
20
     */
21 10
    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

21
    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...
22
    {
23 10
        if ($user->isSuperAdmin()) {
24 9
            return true;
25
        }
26 2
        return null;
27
    }
28
29
    // You can create a user if you are not a simple user
30
    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

30
    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...
31
    {
32
33
        return true;
34
    }
35
36
37
    // You can store a user if you are not a simple user
38
    public function store(User $user, Tournament $tournament)
0 ignored issues
show
Unused Code introduced by
The parameter $tournament 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

38
    public function store(User $user, /** @scrutinizer ignore-unused */ Tournament $tournament)

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

38
    public function store(/** @scrutinizer ignore-unused */ User $user, Tournament $tournament)

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...
39
    {
40
        return true;
41
    }
42
43
44 9
    public function edit(User $user, Tournament $tournament)
45
    {
46 9
        return ($tournament->user_id == $user->id || $user->isSuperAdmin());
47
48
    }
49
50
    public function update(User $user, Tournament $tournament)
51
    {
52
        return ($tournament->user_id == $user->id || $user->isSuperAdmin());
53
    }
54
55
    public function destroy(User $user, Tournament $tournament)
56
    {
57
        return ($tournament->user_id == $user->id || $user->isSuperAdmin());
58
    }
59
60
61
}
62