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