Passed
Pull Request — master (#48)
by
unknown
06:40
created

FightersGroupPolicy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 25
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A before() 0 6 2
A store() 0 3 1
A destroy() 0 5 1
1
<?php
2
3
namespace App\Policies;
4
5
use App\FightersGroup;
6
use App\Tournament;
7
use App\User;
8
9
class FightersGroupPolicy
10
{
11
//    use HandlesAuthorization;
12
13
    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

13
    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...
14
    {
15
        if ($user->isSuperAdmin()) {
16
            return true;
17
        }
18
        return null;
19
    }
20
21
22
    // You can store a user if you are not a simple user
23
    public function store(User $user, Tournament $tournament)
24
    {
25
        return ($tournament->user_id == $user->id);
26
    }
27
28
29
    public function destroy(User $user, FightersGroup $tree)
30
    {
31
        $tournament = $tree->championship->tournament;
0 ignored issues
show
Bug Best Practice introduced by
The property championship does not exist on App\FightersGroup. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The property tournament does not seem to exist on Illuminate\Database\Eloquent\Relations\Relation.
Loading history...
Bug introduced by
The property tournament does not seem to exist on Illuminate\Database\Eloquent\Builder.
Loading history...
32
//        dd($tournament);
33
        return ($tournament->user_id == $user->id);
0 ignored issues
show
Bug introduced by
The property user_id does not seem to exist on DateTimeZone.
Loading history...
34
35
    }
36
37
38
}
39