1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NotificationChannels\OneSignal\Traits\Categories; |
4
|
|
|
|
5
|
|
|
trait AppearanceHelpers |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Set the iOS badge increment count. |
9
|
|
|
* |
10
|
|
|
* @param int $count |
11
|
|
|
* |
12
|
|
|
* @return $this |
13
|
|
|
*/ |
14
|
1 |
|
public function incrementIosBadgeCount(int $count = 1) |
15
|
|
|
{ |
16
|
1 |
|
return $this->setParameter('ios_badgeType', 'Increase') |
|
|
|
|
17
|
1 |
|
->setParameter('ios_badgeCount', $count); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Set the iOS badge decrement count. |
22
|
|
|
* |
23
|
|
|
* @param int $count |
24
|
|
|
* |
25
|
|
|
* @return $this |
26
|
|
|
*/ |
27
|
1 |
|
public function decrementIosBadgeCount(int $count = 1) |
28
|
|
|
{ |
29
|
1 |
|
return $this->setParameter('ios_badgeType', 'Increase') |
|
|
|
|
30
|
1 |
|
->setParameter('ios_badgeCount', -1 * $count); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Set the iOS badge count. |
35
|
|
|
* |
36
|
|
|
* @param int $count |
37
|
|
|
* |
38
|
|
|
* @return $this |
39
|
|
|
*/ |
40
|
1 |
|
public function setIosBadgeCount(int $count) |
41
|
|
|
{ |
42
|
1 |
|
return $this->setParameter('ios_badgeType', 'SetTo') |
|
|
|
|
43
|
1 |
|
->setParameter('ios_badgeCount', $count); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Set the iOS Sound. |
48
|
|
|
* |
49
|
|
|
* @param string $soundUrl |
50
|
|
|
* |
51
|
|
|
* @return $this |
52
|
|
|
*/ |
53
|
|
|
public function setIosSound(string $soundUrl) |
54
|
|
|
{ |
55
|
|
|
return $this->setParameter('ios_sound', $soundUrl); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Set the Android Sound. |
60
|
|
|
* |
61
|
|
|
* @param string $soundUrl |
62
|
|
|
* |
63
|
|
|
* @return $this |
64
|
|
|
*/ |
65
|
|
|
public function setAndroidSound(string $soundUrl) |
66
|
|
|
{ |
67
|
|
|
return $this->setParameter('android_sound', $soundUrl); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Set the Windows Sound. |
72
|
|
|
* |
73
|
|
|
* @param string $soundUrl |
74
|
|
|
* |
75
|
|
|
* @return $this |
76
|
|
|
*/ |
77
|
|
|
public function setWindowsSound(string $soundUrl) |
78
|
|
|
{ |
79
|
|
|
return $this->setParameter('wp_sound', $soundUrl) |
|
|
|
|
80
|
|
|
->setParameter('wp_wns_sound', $soundUrl); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Set the Sound for all Systems. |
85
|
|
|
* |
86
|
|
|
* @param string $soundUrl |
87
|
|
|
* |
88
|
|
|
* @return $this |
89
|
|
|
*/ |
90
|
|
|
public function setSound(string $soundUrl) |
91
|
|
|
{ |
92
|
|
|
return $this->setAndroidSound($soundUrl) |
93
|
|
|
->setIosSound($soundUrl) |
94
|
|
|
->setWindowsSound($soundUrl); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Set the message icon. |
99
|
|
|
* |
100
|
|
|
* @param string $iconPath |
101
|
|
|
* |
102
|
|
|
* @deprecated use setIcon instead |
103
|
|
|
* |
104
|
|
|
* @return $this |
105
|
|
|
*/ |
106
|
9 |
|
public function icon(string $iconPath) |
107
|
|
|
{ |
108
|
9 |
|
return $this->setIcon($iconPath); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Set the message icon. |
113
|
|
|
* |
114
|
|
|
* @param string $iconPath |
115
|
|
|
* |
116
|
|
|
* @return $this |
117
|
|
|
*/ |
118
|
10 |
|
public function setIcon(string $iconPath) |
119
|
|
|
{ |
120
|
10 |
|
return $this->setParameter('chrome_web_icon', $iconPath) |
|
|
|
|
121
|
10 |
|
->setParameter('chrome_icon', $iconPath) |
122
|
10 |
|
->setParameter('adm_small_icon', $iconPath) |
123
|
10 |
|
->setParameter('small_icon', $iconPath); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
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.