1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* (c) Alexander Zhukov <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Zbox\UnifiedPush\Notification; |
11
|
|
|
|
12
|
|
|
use Zbox\UnifiedPush\NotificationService\NotificationServices; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class Notification |
16
|
|
|
* @package Zbox\UnifiedPush\Notification |
17
|
|
|
*/ |
18
|
|
|
class Notification |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* An arbitrary, opaque value that identifies this notification. |
22
|
|
|
* This identifier is used for reporting errors to your server |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $identifier; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
protected $type; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $payload; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var \ArrayIterator |
40
|
|
|
*/ |
41
|
|
|
protected $recipients; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Custom properties |
45
|
|
|
* |
46
|
|
|
* @var array |
47
|
|
|
*/ |
48
|
|
|
private $customNotificationData = array(); |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
|
|
public function getIdentifier() |
54
|
|
|
{ |
55
|
|
|
return $this->identifier; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $identifier |
60
|
|
|
* @return Notification |
61
|
|
|
*/ |
62
|
|
|
public function setIdentifier($identifier) |
63
|
|
|
{ |
64
|
|
|
$this->identifier = $identifier; |
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function getType() |
72
|
|
|
{ |
73
|
|
|
return $this->type; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $type |
78
|
|
|
* @return $this |
79
|
|
|
*/ |
80
|
|
|
public function setType($type) |
81
|
|
|
{ |
82
|
|
|
$this->type = NotificationServices::validateServiceName($type); |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
|
|
public function getPayload() |
90
|
|
|
{ |
91
|
|
|
return $this->payload; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $payload |
96
|
|
|
* @return $this |
97
|
|
|
*/ |
98
|
|
|
public function setPayload($payload) |
99
|
|
|
{ |
100
|
|
|
$this->payload = $payload; |
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return \ArrayIterator |
106
|
|
|
*/ |
107
|
|
|
public function getRecipients() |
108
|
|
|
{ |
109
|
|
|
return $this->recipients; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param \ArrayIterator $recipients |
114
|
|
|
* @return $this |
115
|
|
|
*/ |
116
|
|
|
public function setRecipients(\ArrayIterator $recipients) |
117
|
|
|
{ |
118
|
|
|
$this->recipients = $recipients; |
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return array |
124
|
|
|
*/ |
125
|
|
|
public function getCustomNotificationData() |
126
|
|
|
{ |
127
|
|
|
return $this->customNotificationData; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param array $customNotificationData |
132
|
|
|
* @return $this |
133
|
|
|
*/ |
134
|
|
|
public function setCustomNotificationData($customNotificationData) |
|
|
|
|
135
|
|
|
{ |
136
|
|
|
$this->customNotificationData = $customNotificationData; |
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.