1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the FirebaseCloudMessagingBundle |
4
|
|
|
* |
5
|
|
|
* (c) Artem Henvald <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace Fresh\FirebaseCloudMessagingBundle\Message\Part\Options; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class Options. |
17
|
|
|
* |
18
|
|
|
* Set of options that can be used to change default behaviour of FCM notification. |
19
|
|
|
* |
20
|
|
|
* @author Artem Henvald <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
final class Options implements OptionsInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Default `time_to_live` option value is 4 weeks (it is also the maximum TTL allowed for FCM). |
26
|
|
|
* In seconds it is 60 seconds * 60 minutes * 24 hours * 28 days = 2419200 seconds. |
27
|
|
|
*/ |
28
|
|
|
public const DEFAULT_TTL_IN_SECONDS = 2419200; |
29
|
|
|
|
30
|
|
|
/** @var string */ |
31
|
|
|
private $collapseKey = ''; |
32
|
|
|
|
33
|
|
|
/** @var string */ |
34
|
|
|
private $priority = Priority::NORMAL; |
35
|
|
|
|
36
|
|
|
/** @var bool */ |
37
|
|
|
private $contentAvailable = false; |
38
|
|
|
|
39
|
|
|
/** @var bool */ |
40
|
|
|
private $mutableContent = false; |
41
|
|
|
|
42
|
|
|
/** @var int */ |
43
|
|
|
private $timeToLive = self::DEFAULT_TTL_IN_SECONDS; |
44
|
|
|
|
45
|
|
|
/** @var string */ |
46
|
|
|
private $restrictedPackageName = ''; |
47
|
|
|
|
48
|
|
|
/** @var bool */ |
49
|
|
|
private $dryRun = false; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string $collapseKey |
53
|
|
|
* |
54
|
|
|
* @return $this |
55
|
|
|
*/ |
56
|
|
|
public function setCollapseKey(string $collapseKey): self |
57
|
|
|
{ |
58
|
|
|
$this->collapseKey = $collapseKey; |
59
|
|
|
|
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
|
|
public function getCollapseKey(): string |
67
|
|
|
{ |
68
|
|
|
return $this->collapseKey; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param string $priority |
73
|
|
|
* |
74
|
|
|
* @return $this |
75
|
|
|
*/ |
76
|
|
|
public function setPriority(string $priority): self |
77
|
|
|
{ |
78
|
|
|
$this->priority = $priority; |
79
|
|
|
|
80
|
|
|
return $this; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* {@inheritdoc} |
85
|
|
|
*/ |
86
|
|
|
public function getPriority(): string |
87
|
|
|
{ |
88
|
|
|
return $this->priority; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param bool $contentAvailable |
93
|
|
|
* |
94
|
|
|
* @return $this |
95
|
|
|
*/ |
96
|
|
|
public function setContentAvailable(bool $contentAvailable): self |
97
|
|
|
{ |
98
|
|
|
$this->contentAvailable = $contentAvailable; |
99
|
|
|
|
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* {@inheritdoc} |
105
|
|
|
*/ |
106
|
|
|
public function isContentAvailable(): bool |
107
|
|
|
{ |
108
|
|
|
return $this->contentAvailable; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param bool $mutableContent |
113
|
|
|
*/ |
114
|
|
|
public function setMutableContent(bool $mutableContent): self |
115
|
|
|
{ |
116
|
|
|
$this->mutableContent = $mutableContent; |
117
|
|
|
|
118
|
|
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* {@inheritdoc} |
123
|
|
|
*/ |
124
|
|
|
public function isMutableContent(): bool |
125
|
|
|
{ |
126
|
|
|
return $this->mutableContent; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @param int $timeToLive |
131
|
|
|
* |
132
|
|
|
* @return $this |
133
|
|
|
*/ |
134
|
|
|
public function setTimeToLive(int $timeToLive): self |
135
|
|
|
{ |
136
|
|
|
$this->timeToLive = $timeToLive; |
137
|
|
|
|
138
|
|
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* {@inheritdoc} |
143
|
|
|
*/ |
144
|
|
|
public function getTimeToLive(): int |
145
|
|
|
{ |
146
|
|
|
return $this->timeToLive; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param string $restrictedPackageName |
151
|
|
|
* |
152
|
|
|
* @return $this |
153
|
|
|
*/ |
154
|
|
|
public function setRestrictedPackageName(string $restrictedPackageName): self |
155
|
|
|
{ |
156
|
|
|
$this->restrictedPackageName = $restrictedPackageName; |
157
|
|
|
|
158
|
|
|
return $this; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* {@inheritdoc} |
163
|
|
|
*/ |
164
|
|
|
public function getRestrictedPackageName(): string |
165
|
|
|
{ |
166
|
|
|
return $this->restrictedPackageName; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @param bool $dryRun |
171
|
|
|
* |
172
|
|
|
* @return $this |
173
|
|
|
*/ |
174
|
|
|
public function setDryRun(bool $dryRun): self |
175
|
|
|
{ |
176
|
|
|
$this->dryRun = $dryRun; |
177
|
|
|
|
178
|
|
|
return $this; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* {@inheritdoc} |
183
|
|
|
*/ |
184
|
|
|
public function isDryRun(): bool |
185
|
|
|
{ |
186
|
|
|
return $this->dryRun; |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
|