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