1 | <?php |
||
8 | trait ButtonHelpers |
||
9 | { |
||
10 | /** |
||
11 | * Add a web button to the message. |
||
12 | * |
||
13 | * @param OneSignalWebButton $button |
||
14 | * |
||
15 | * @return $this |
||
16 | */ |
||
17 | public function setWebButton(OneSignalWebButton $button) |
||
21 | |||
22 | /** |
||
23 | * Adds more than one web button to the message. |
||
24 | * |
||
25 | * @param array[OnSignalWebButton] $buttons |
||
26 | * |
||
27 | * @return $this |
||
28 | */ |
||
29 | public function setWebButtons(array $buttons) |
||
37 | |||
38 | /** |
||
39 | * Add a native button to the message. |
||
40 | * |
||
41 | * @param OneSignalButton $button |
||
42 | * |
||
43 | * @return $this |
||
44 | */ |
||
45 | public function setButton(OneSignalButton $button) |
||
49 | |||
50 | /** |
||
51 | * Adds more than one native button to the message. |
||
52 | * |
||
53 | * @param array $buttons |
||
54 | * |
||
55 | * @return $this |
||
56 | */ |
||
57 | public function setButtons(array $buttons) |
||
65 | } |
||
66 |
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.