TeamPolicy::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
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 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
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