ApnMessage::category()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace SemyonChetvertnyh\ApnNotificationChannel;
4
5
class ApnMessage
6
{
7
    /**
8
     * The title of the notification.
9
     *
10
     * @var string
11
     */
12
    public $title;
13
14
    /**
15
     * The subtitle of the notification.
16
     *
17
     * @var string
18
     */
19
    public $subtitle;
20
21
    /**
22
     * The body of the notification.
23
     *
24
     * @var string
25
     */
26
    public $body;
27
28
    /**
29
     * The badge of the notification.
30
     *
31
     * @var int
32
     */
33
    public $badge;
34
35
    /**
36
     * The sound for the notification.
37
     *
38
     * @var string|null
39
     */
40
    public $sound;
41
42
    /**
43
     * The category for action button.
44
     *
45
     * @var string|null
46
     * */
47
    public $category;
48
49
    /**
50
     * Provide this key with a string value that represents the app-specific identifier for grouping notifications.
51
     *
52
     * @var string
53
     */
54
    public $threadId;
55
56
    /**
57
     * Additional data of the notification.
58
     *
59
     * @var array
60
     */
61
    public $custom = [];
62
63
    /**
64
     * The key to a title string in the Localizable.strings file for the current localization.
65
     *
66
     * @var string|null
67
     */
68
    public $titleLocKey;
69
70
    /**
71
     * Variable string values to appear in place of the format specifiers in title-loc-key.
72
     *
73
     * @var string[]|null
74
     */
75
    public $titleLocArgs;
76
77
    /**
78
     * If a string is specified, the iOS system displays an alert that includes the Close and View buttons.
79
     *
80
     * @var string|null
81
     */
82
    public $actionLocKey;
83
84
    /**
85
     * A key to an alert-message string in a Localizable.strings file for the current localization.
86
     *
87
     * @var string
88
     */
89
    public $locKey;
90
91
    /**
92
     * Variable string values to appear in place of the format specifiers in loc-key.
93
     *
94
     * @var array
95
     */
96
    public $locArgs;
97
98
    /**
99
     * The filename of an image file in the app bundle, with or without the filename extension.
100
     *
101
     * @var string
102
     */
103
    public $launchImage;
104
105
    /**
106
     * Value indicating incoming resource in the notification.
107
     *
108
     * @var bool|null
109
     */
110
    protected $contentAvailable;
111
112
    /**
113
     * Include this key with a value of true to configure a mutable content notification.
114
     *
115
     * @var bool
116
     */
117
    protected $mutableContent;
118
119
    /**
120
     * Create an instance of APN message.
121
     *
122
     * @param  string|null  $title
123
     * @param  string|null  $body
124
     * @param  int|null  $badge
125
     * @return static
126
     */
127
    public static function create($title = null, $body = null, $badge = null)
128
    {
129
        return new static($title, $body, $badge);
130
    }
131
132
    /**
133
     * Create an instance of APN message.
134
     *
135
     * @param  string|null  $title
136
     * @param  string|null  $body
137
     * @param  int|null  $badge
138
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
139
     */
140
    public function __construct($title = null, $body = null, $badge = null)
141
    {
142
        $this->title = $title;
143
        $this->body = $body;
144
        $this->badge = $badge;
145
    }
146
147
    /**
148
     * Set a title.
149
     *
150
     * @param  string  $title
151
     * @return $this
152
     */
153
    public function title($title)
154
    {
155
        $this->title = $title;
156
157
        return $this;
158
    }
159
160
    /**
161
     * Set a subtitle.
162
     *
163
     * @param  string  $subtitle
164
     * @return $this
165
     */
166
    public function subtitle($subtitle)
167
    {
168
        $this->subtitle = $subtitle;
169
170
        return $this;
171
    }
172
173
    /**
174
     * Set a body.
175
     *
176
     * @param  string  $body
177
     * @return $this
178
     */
179
    public function body($body)
180
    {
181
        $this->body = $body;
182
183
        return $this;
184
    }
185
186
    /**
187
     * Set a badge.
188
     *
189
     * @param  int  $badge
190
     * @return $this
191
     */
192
    public function badge($badge)
193
    {
194
        $this->badge = $badge;
195
196
        return $this;
197
    }
198
199
    /**
200
     * Set a sound.
201
     *
202
     * @param  string|null  $sound
203
     * @return $this
204
     */
205
    public function sound($sound = 'default')
206
    {
207
        $this->sound = $sound;
208
209
        return $this;
210
    }
211
212
    /**
213
     * Set a category.
214
     *
215
     * @param  string|null  $category
216
     * @return $this
217
     */
218
    public function category($category)
219
    {
220
        $this->category = $category;
221
222
        return $this;
223
    }
224
225
    /**
226
     * Set a title-loc-key.
227
     *
228
     * @param  string|null  $titleLocKey
229
     * @return $this
230
     */
231
    public function titleLocKey($titleLocKey = null)
232
    {
233
        $this->titleLocKey = $titleLocKey;
234
235
        return $this;
236
    }
237
238
    /**
239
     * Set the title-loc-args.
240
     *
241
     * @param  array|null  $titleLocArgs
242
     * @return $this
243
     */
244
    public function titleLocArgs(array $titleLocArgs = null)
245
    {
246
        $this->titleLocArgs = $titleLocArgs;
247
248
        return $this;
249
    }
250
251
    /**
252
     * Set an action-loc-key.
253
     *
254
     * @param  string|null  $actionLocKey
255
     * @return $this
256
     */
257
    public function actionLocKey($actionLocKey = null)
258
    {
259
        $this->actionLocKey = $actionLocKey;
260
261
        return $this;
262
    }
263
264
    /**
265
     * Set a loc-key.
266
     *
267
     * @param  string  $locKey
268
     * @return $this
269
     */
270
    public function setLocKey($locKey)
271
    {
272
        $this->locKey = $locKey;
273
274
        return $this;
275
    }
276
277
    /**
278
     * Set the loc-args.
279
     *
280
     * @param  array  $locArgs
281
     * @return $this
282
     */
283
    public function setLocArgs($locArgs)
284
    {
285
        $this->locArgs = $locArgs;
286
287
        return $this;
288
    }
289
290
    /**
291
     * Set a launch-image.
292
     *
293
     * @param  string  $launchImage
294
     * @return $this
295
     */
296
    public function launchImage($launchImage)
297
    {
298
        $this->launchImage = $launchImage;
299
300
        return $this;
301
    }
302
303
    /**
304
     * Set a content availability.
305
     *
306
     * @param  bool|null  $value
307
     * @return $this
308
     */
309
    public function contentAvailability($value = true)
310
    {
311
        $this->contentAvailable = $value;
312
313
        return $this;
314
    }
315
316
    /**
317
     * Get a content availability.
318
     *
319
     * @return bool|null
320
     */
321
    public function isContentAvailable()
322
    {
323
        return $this->contentAvailable;
324
    }
325
326
    /**
327
     * Set the mutable-content key for Notification Service Extensions on iOS10.
328
     * @see http://bit.ly/mutable-content
329
     *
330
     * @param  bool  $value
331
     * @return $this
332
     */
333
    public function mutableContent($value = true)
334
    {
335
        $this->mutableContent = $value;
336
337
        return $this;
338
    }
339
340
    /**
341
     * Determine the content is mutable.
342
     *
343
     * @return bool|null
344
     */
345
    public function hasMutableContent()
346
    {
347
        return $this->mutableContent;
348
    }
349
350
    /**
351
     * Set a thread ID.
352
     *
353
     * @param  string  $threadId
354
     * @return $this
355
     */
356
    public function threadId($threadId)
357
    {
358
        $this->threadId = $threadId;
359
360
        return $this;
361
    }
362
363
    /**
364
     * Add custom data to the notification.
365
     *
366
     * @param  string  $key
367
     * @param  mixed  $value
368
     * @return $this
369
     */
370
    public function custom($key, $value)
371
    {
372
        $this->custom[$key] = $value;
373
374
        return $this;
375
    }
376
377
    /**
378
     * Override the custom data of the notification.
379
     *
380
     * @param  array  $custom
381
     * @return $this
382
     */
383
    public function setCustom($custom)
384
    {
385
        $this->custom = $custom;
386
387
        return $this;
388
    }
389
}
390