1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NotificationChannels\OneSignal\Traits\Categories; |
4
|
|
|
|
5
|
|
|
trait AttachmentHelpers |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Set an Image only for iOS. |
9
|
|
|
* |
10
|
|
|
* @param string $imageUrl |
11
|
|
|
* |
12
|
|
|
* @return $this |
13
|
|
|
*/ |
14
|
1 |
|
public function setIosAttachment(string $imageUrl) |
15
|
|
|
{ |
16
|
1 |
|
return $this->setParameter('ios_attachments', ['id1' => $imageUrl]); |
|
|
|
|
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Set multiple Images only for iOS. |
21
|
|
|
* |
22
|
|
|
* @param array $images |
23
|
|
|
* |
24
|
|
|
* @return $this |
25
|
|
|
*/ |
26
|
|
|
public function setIosAttachments(array $images) |
27
|
|
|
{ |
28
|
|
|
return $this->setParameter('ios_attachments', $images); |
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Set the Big Picture Image only for Android. |
33
|
|
|
* |
34
|
|
|
* @param string $imageUrl |
35
|
|
|
* |
36
|
|
|
* @return $this |
37
|
|
|
*/ |
38
|
1 |
|
public function setAndroidBigPicture(string $imageUrl) |
39
|
|
|
{ |
40
|
1 |
|
return $this->setParameter('big_picture', $imageUrl); |
|
|
|
|
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Set the Big Picture Image only for FireOS (Amazon). |
45
|
|
|
* |
46
|
|
|
* @param string $imageUrl |
47
|
|
|
* |
48
|
|
|
* @return $this |
49
|
|
|
*/ |
50
|
1 |
|
public function setAmazonBigPicture(string $imageUrl) |
51
|
|
|
{ |
52
|
1 |
|
return $this->setParameter('adm_big_picture', $imageUrl); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Set the Big Picture Image only for Chrome. |
57
|
|
|
* |
58
|
|
|
* @param string $imageUrl |
59
|
|
|
* |
60
|
|
|
* @return $this |
61
|
|
|
*/ |
62
|
1 |
|
public function setChromeBigPicture(string $imageUrl) |
63
|
|
|
{ |
64
|
1 |
|
return $this->setParameter('chrome_big_picture', $imageUrl); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Set the additional Data for all Platforms. |
69
|
|
|
* @param array $data |
70
|
|
|
* |
71
|
|
|
* @return $this |
72
|
|
|
*/ |
73
|
|
|
public function setData(array $data) |
74
|
|
|
{ |
75
|
|
|
return $this->setParameter('data', $data); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Set the additional URL for all Platforms. |
80
|
|
|
* @param string $url |
81
|
|
|
* |
82
|
|
|
* @return $this |
83
|
|
|
*/ |
84
|
6 |
|
public function setUrl(string $url) |
85
|
|
|
{ |
86
|
6 |
|
return $this->setParameter('url', $url); |
|
|
|
|
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Set an image to all possible attachment variables. |
91
|
|
|
* |
92
|
|
|
* @param string $imageUrl |
93
|
|
|
* |
94
|
|
|
* @return $this |
95
|
|
|
*/ |
96
|
1 |
|
public function setImageAttachments(string $imageUrl) |
97
|
|
|
{ |
98
|
1 |
|
return $this->setIosAttachment($imageUrl) |
99
|
1 |
|
->setAndroidBigPicture($imageUrl) |
100
|
1 |
|
->setAmazonBigPicture($imageUrl) |
101
|
1 |
|
->setChromeBigPicture($imageUrl); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
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.