1 | <?php |
||
7 | trait UserOnly |
||
8 | { |
||
9 | /** USER |
||
10 | * A User can have permissions explicitly assigned to it |
||
11 | * |
||
12 | * @return mixed |
||
13 | */ |
||
14 | 13 | public function permissions() |
|
18 | |||
19 | /** |
||
20 | * Negate a permission from a User |
||
21 | * |
||
22 | * @param $permission |
||
23 | */ |
||
24 | 1 | public function negatePermission($permission) |
|
28 | |||
29 | /** |
||
30 | * Negate an array of permissions from a User |
||
31 | * |
||
32 | * @param $permissions |
||
33 | */ |
||
34 | 1 | public function negatePermissions(array $permissions) |
|
38 | |||
39 | /** |
||
40 | * First try the cache to return the collection, |
||
41 | * then fetch it from the database. |
||
42 | * |
||
43 | * See @cacheGetNegatedPermissions() |
||
44 | * |
||
45 | * @return mixed |
||
46 | */ |
||
47 | 3 | public function getNegatedPermissions() |
|
57 | |||
58 | /** |
||
59 | * Return a collection of permissions that |
||
60 | * are negated for a User |
||
61 | * |
||
62 | * @return mixed |
||
63 | */ |
||
64 | 3 | protected function cacheGetNegatedPermissions() |
|
68 | } |
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.