1 | <?php |
||
8 | trait ButtonHelpers |
||
9 | { |
||
10 | |||
11 | |||
12 | /** |
||
13 | * Add a web button to the message. |
||
14 | * |
||
15 | * @param OneSignalWebButton $button |
||
16 | * |
||
17 | * @return $this |
||
18 | */ |
||
19 | 2 | public function setWebButton(OneSignalWebButton $button) |
|
23 | |||
24 | /** |
||
25 | * Adds more than one web button to the message. |
||
26 | * |
||
27 | * @param array[OnSignalWebButton] $buttons |
||
28 | * |
||
29 | * @return $this |
||
30 | */ |
||
31 | public function setWebButtons(array $buttons) |
||
39 | |||
40 | |||
41 | |||
42 | /** |
||
43 | * Add a native button to the message. |
||
44 | * |
||
45 | * @param OneSignalButton $button |
||
46 | * |
||
47 | * @return $this |
||
48 | */ |
||
49 | 1 | public function setButton(OneSignalButton $button) |
|
53 | |||
54 | |||
55 | /** |
||
56 | * Adds more than one native button to the message. |
||
57 | * |
||
58 | * @param array $buttons |
||
59 | * |
||
60 | * @return $this |
||
61 | */ |
||
62 | public function setButtons(array $buttons) |
||
70 | } |
||
71 |
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.