1 | <?php |
||
17 | trait RoleTrait |
||
18 | { |
||
19 | use HasPermissionTrait; |
||
20 | |||
21 | /** |
||
22 | * Gives the permission or an array of permissions |
||
23 | * @param string|Permission|array $permission |
||
24 | * @return bool |
||
25 | */ |
||
26 | public function givePermission($permission) |
||
37 | |||
38 | /** |
||
39 | * Revokes the permissions of the role |
||
40 | * @param $permission |
||
41 | * @return |
||
42 | */ |
||
43 | public function revokePermission($permission) |
||
52 | |||
53 | /** |
||
54 | * Revokes all permissions of the role |
||
55 | * @return boolean |
||
56 | */ |
||
57 | public function revokeAllPermissions() |
||
64 | |||
65 | /** |
||
66 | * Gets all permissions for the role |
||
67 | * @return Permission[] |
||
68 | */ |
||
69 | public function getAllPermissions() |
||
79 | |||
80 | /** |
||
81 | * Finds the role by its name |
||
82 | * @param string $name |
||
83 | * @return RoleTrait |
||
84 | */ |
||
85 | public static function find($name) |
||
89 | |||
90 | /** |
||
91 | * Creates a role |
||
92 | * @param $arguments |
||
93 | * @return RoleTrait |
||
94 | */ |
||
95 | public static function create($arguments) |
||
109 | |||
110 | /** |
||
111 | * Finds the role, if it does not exists, the role will be created |
||
112 | * @param $name |
||
113 | * @return RoleTrait |
||
114 | */ |
||
115 | public static function findOrCreate($name) |
||
124 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.