1 | <?php |
||
10 | trait Rewardable |
||
11 | { |
||
12 | /** |
||
13 | * Get the promocodes that are related to user. |
||
14 | * |
||
15 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
16 | */ |
||
17 | public function promocodes() |
||
22 | |||
23 | /** |
||
24 | * Redeem promocode to user and get callback. |
||
25 | * |
||
26 | * @param string $code |
||
27 | * @param null|\Closure $callback |
||
28 | * |
||
29 | * @return null|\Gabievi\Promocodes\Models\Promocode |
||
30 | * @throws AlreadyUsedException |
||
31 | */ |
||
32 | public function redeemCode($code, $callback = null) |
||
36 | |||
37 | /** |
||
38 | * Apply promocode to user and get callback. |
||
39 | * |
||
40 | * @param string $code |
||
41 | * @param null|\Closure $callback |
||
42 | * |
||
43 | * @return bool|null|\Gabievi\Promocodes\Models\Promocode |
||
44 | * @throws AlreadyUsedException |
||
45 | */ |
||
46 | public function applyCode($code, $callback = null) |
||
78 | } |
||
79 |
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.