Completed
Push — master ( 7d9868...4fd283 )
by Daniel
01:06
created

HasGates::gateAllowsGuests()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Fireworkweb\Gates\Traits;
4
5
trait HasGates
6
{
7
    public function gateAllows()
8
    {
9
        return true;
10
    }
11
12
    public function gateAllowsGuests($user = null)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
13
    {
14
        return true;
15
    }
16
17
    public function gateDenies()
18
    {
19
        return false;
20
    }
21
22
    public function gateDeniesGuests($user = null)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24
        return false;
25
    }
26
27
28
    protected static function gateRouteName(): string
29
    {
30
        // @TODO: add magic way
31
        return '';
32
    }
33
34
    protected static function gateAbilities(): array
35
    {
36
        return [];
37
    }
38
39
    protected static function gateResourceAbilities(): array
40
    {
41
        return [
42
            'index' => 'index',
43
            'create' => 'create',
44
            'store' => 'store',
45
            'show' => 'show',
46
            'edit' => 'edit',
47
            'update' => 'update',
48
            'destroy' => 'destroy',
49
        ];
50
    }
51
52
    public static function gateRegister(): void
53
    {
54
        gate()->resource(
55
            static::gateRouteName(),
56
            static::class,
57
            static::gateAbilities()
58
        );
59
    }
60
}
61