Completed
Push — master ( edb43e...425779 )
by Abdelrahman
10:35
created

RoleHandler::deleted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
declare(strict_types=1);
17
18
namespace Rinvex\Fort\Handlers;
19
20
use Rinvex\Fort\Models\Role;
21
use Rinvex\Fort\Models\User;
22
use Rinvex\Fort\Models\Ability;
23
24
class RoleHandler
25
{
26
    /**
27
     * Listen to the Role updated event.
28
     *
29
     * @param \Rinvex\Fort\Models\Role $role
30
     *
31
     * @return void
32
     */
33
    public function updated(Role $role)
0 ignored issues
show
Unused Code introduced by
The parameter $role 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...
34
    {
35
        Ability::forgetCache();
36
        User::forgetCache();
37
    }
38
39
    /**
40
     * Listen to the Role deleted event.
41
     *
42
     * @param \Rinvex\Fort\Models\Role $role
43
     *
44
     * @return void
45
     */
46
    public function deleted(Role $role)
0 ignored issues
show
Unused Code introduced by
The parameter $role 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...
47
    {
48
        Ability::forgetCache();
49
        User::forgetCache();
50
    }
51
52
    /**
53
     * Listen to the Role attached event.
54
     *
55
     * @param \Rinvex\Fort\Models\Role $role
56
     *
57
     * @return void
58
     */
59
    public function attached(Role $role)
0 ignored issues
show
Unused Code introduced by
The parameter $role 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...
60
    {
61
        Ability::forgetCache();
62
        User::forgetCache();
63
    }
64
65
    /**
66
     * Listen to the Role synced event.
67
     *
68
     * @param \Rinvex\Fort\Models\Role $role
69
     *
70
     * @return void
71
     */
72
    public function synced(Role $role)
0 ignored issues
show
Unused Code introduced by
The parameter $role 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...
73
    {
74
        Ability::forgetCache();
75
        User::forgetCache();
76
    }
77
78
    /**
79
     * Listen to the Role detached event.
80
     *
81
     * @param \Rinvex\Fort\Models\Role $role
82
     *
83
     * @return void
84
     */
85
    public function detached(Role $role)
0 ignored issues
show
Unused Code introduced by
The parameter $role 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...
86
    {
87
        Ability::forgetCache();
88
        User::forgetCache();
89
    }
90
91
    /**
92
     * Listen to the Role validating event.
93
     *
94
     * @param \Rinvex\Fort\Models\Role $role
95
     * @param string                   $event
96
     *
97
     * @return void
98
     */
99
    public function validating(Role $role, $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event 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...
100
    {
101
        if (! $role->slug) {
102
            // Early auto generate slugs before validation, since it's required
103
            if ($role->exists && $role->getSlugOptions()->generateSlugsOnUpdate) {
104
                $role->generateSlug();
105
            } elseif ($role->getSlugOptions()->generateSlugsOnCreate) {
106
                $role->generateSlug();
107
            }
108
        }
109
    }
110
}
111