1 | <?php |
||
9 | trait ButtonHelpers |
||
10 | { |
||
11 | /** |
||
12 | * Add a web button to the message. |
||
13 | * |
||
14 | * @param OneSignalWebButton $button |
||
15 | * |
||
16 | * @return $this |
||
17 | */ |
||
18 | 1 | public function webButton(OneSignalWebButton $button) |
|
23 | /** |
||
24 | * Adds more than one web button to the message. |
||
25 | * |
||
26 | * @param array[OnSignalWebButton] $buttons |
||
27 | * |
||
28 | * @return $this |
||
29 | */ |
||
30 | public function webButtons(array $buttons) |
||
35 | /** |
||
36 | * Add a native button to the message. |
||
37 | * |
||
38 | * @param OneSignalButton $button |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | 1 | public function button(OneSignalButton $button) |
|
46 | |||
47 | /** |
||
48 | * Adds more than one native button to the message. |
||
49 | * |
||
50 | * @param array $buttons |
||
51 | * |
||
52 | * @return $this |
||
53 | */ |
||
54 | public function buttons(array $buttons) |
||
58 | } |
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.