TeamPolicy   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 45
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0
wmc 7

4 Methods

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

19
    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...
20
    {
21
        if ($user->isSuperAdmin()) {
22
            return true;
23
        }
24
        return null;
25
    }
26
27
    // You can create a user if you are not a simple user
28
    public function create(User $user, Tournament $tournament)
29
    {
30
        return $user->isOwner($tournament);
31
    }
32
33
34
    public function edit(User $user, Tournament $tournament)
35
    {
36
        return $user->isOwner($tournament);
37
    }
38
39
40
    // You can store a user if you are not a simple user
41
    public function store(User $user, Tournament $tournament)
42
    {
43
        return $user->isOwner($tournament);
44
    }
45
46
    public function update(User $user, Tournament $tournament)
47
    {
48
        return $user->isOwner($tournament);
49
    }
50
51
    public function delete(User $user, \Xoco70\LaravelTournaments\Models\Tournament $tournament)
52
    {
53
        return $user->isOwner($tournament);
54
    }
55
56
}
57