Completed
Push — master ( 0d4684...fff311 )
by Chris
01:24
created

AndroidNotification::getTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace NotificationChannels\Fcm\Resources;
4
5
class AndroidNotification implements FcmResource
6
{
7
    /**
8
     * @var string|null
9
     */
10
    protected $title;
11
12
    /**
13
     * @var string|null
14
     */
15
    protected $body;
16
17
    /**
18
     * @var string|null
19
     */
20
    protected $icon;
21
22
    /**
23
     * @var string|null
24
     */
25
    protected $color;
26
27
    /**
28
     * @var string|null
29
     */
30
    protected $sound;
31
32
    /**
33
     * @var string|null
34
     */
35
    protected $tag;
36
37
    /**
38
     * @var string|null
39
     */
40
    protected $clickAction;
41
42
    /**
43
     * @var string|null
44
     */
45
    protected $bodyLocKey;
46
47
    /**
48
     * @var string[]|null
49
     */
50
    protected $bodyLocArgs;
51
52
    /**
53
     * @var string|null
54
     */
55
    protected $titleLocKey;
56
57
    /**
58
     * @var string[]|null
59
     */
60
    protected $titleLocArgs;
61
62
    /**
63
     * @var string|null
64
     */
65
    protected $channelId;
66
67
    /**
68
     * @var string|null
69
     */
70
    protected $ticker;
71
72
    /**
73
     * @var bool|null
74
     */
75
    protected $sticky;
76
77
    /**
78
     * @var string|null
79
     */
80
    protected $eventTime;
81
82
    /**
83
     * @var bool|null
84
     */
85
    protected $localOnly;
86
87
    /**
88
     * @var NotificationPriority|null
89
     */
90
    protected $notificationPriority;
91
92
    /**
93
     * @var bool|null
94
     */
95
    protected $defaultSound;
96
97
    /**
98
     * @var bool|null
99
     */
100
    protected $defaultVibrateTimings;
101
102
    /**
103
     * @var bool|null
104
     */
105
    protected $defaultLightSettings;
106
107
    /**
108
     * @var string[]|null
109
     */
110
    protected $vibrateTimings;
111
112
    /**
113
     * @var Visibility|null
114
     */
115
    protected $visibility;
116
117
    /**
118
     * @var int|null
119
     */
120
    protected $notificationCount;
121
122
    /**
123
     * @var LightSettings|null
124
     */
125
    protected $lightSettings;
126
127
    /**
128
     * @var string|null
129
     */
130
    protected $image;
131
132
    /**
133
     * @return static
134
     */
135
    public static function create(): self
136
    {
137
        return new self;
138
    }
139
140
    /**
141
     * @return string|null
142
     */
143
    public function getTitle(): ?string
144
    {
145
        return $this->title;
146
    }
147
148
    /**
149
     * @param string|null $title
150
     * @return AndroidNotification
151
     */
152
    public function setTitle(?string $title): self
153
    {
154
        $this->title = $title;
155
156
        return $this;
157
    }
158
159
    /**
160
     * @return string|null
161
     */
162
    public function getBody(): ?string
163
    {
164
        return $this->body;
165
    }
166
167
    /**
168
     * @param string|null $body
169
     * @return AndroidNotification
170
     */
171
    public function setBody(?string $body): self
172
    {
173
        $this->body = $body;
174
175
        return $this;
176
    }
177
178
    /**
179
     * @return string|null
180
     */
181
    public function getIcon(): ?string
182
    {
183
        return $this->icon;
184
    }
185
186
    /**
187
     * @param string|null $icon
188
     * @return AndroidNotification
189
     */
190
    public function setIcon(?string $icon): self
191
    {
192
        $this->icon = $icon;
193
194
        return $this;
195
    }
196
197
    /**
198
     * @return string|null
199
     */
200
    public function getColor(): ?string
201
    {
202
        return $this->color;
203
    }
204
205
    /**
206
     * @param string|null $color
207
     * @return AndroidNotification
208
     */
209
    public function setColor(?string $color): self
210
    {
211
        $this->color = $color;
212
213
        return $this;
214
    }
215
216
    /**
217
     * @return string|null
218
     */
219
    public function getSound(): ?string
220
    {
221
        return $this->sound;
222
    }
223
224
    /**
225
     * @param string|null $sound
226
     * @return AndroidNotification
227
     */
228
    public function setSound(?string $sound): self
229
    {
230
        $this->sound = $sound;
231
232
        return $this;
233
    }
234
235
    /**
236
     * @return string|null
237
     */
238
    public function getTag(): ?string
239
    {
240
        return $this->tag;
241
    }
242
243
    /**
244
     * @param string|null $tag
245
     * @return AndroidNotification
246
     */
247
    public function setTag(?string $tag): self
248
    {
249
        $this->tag = $tag;
250
251
        return $this;
252
    }
253
254
    /**
255
     * @return string|null
256
     */
257
    public function getClickAction(): ?string
258
    {
259
        return $this->clickAction;
260
    }
261
262
    /**
263
     * @param string|null $clickAction
264
     * @return AndroidNotification
265
     */
266
    public function setClickAction(?string $clickAction): self
267
    {
268
        $this->clickAction = $clickAction;
269
270
        return $this;
271
    }
272
273
    /**
274
     * @return string|null
275
     */
276
    public function getBodyLocKey(): ?string
277
    {
278
        return $this->bodyLocKey;
279
    }
280
281
    /**
282
     * @param string|null $bodyLocKey
283
     * @return AndroidNotification
284
     */
285
    public function setBodyLocKey(?string $bodyLocKey): self
286
    {
287
        $this->bodyLocKey = $bodyLocKey;
288
289
        return $this;
290
    }
291
292
    /**
293
     * @return string[]|null
294
     */
295
    public function getBodyLocArgs(): ?array
296
    {
297
        return $this->bodyLocArgs;
298
    }
299
300
    /**
301
     * @param string[]|null $bodyLocArgs
302
     * @return AndroidNotification
303
     */
304
    public function setBodyLocArgs(?array $bodyLocArgs): self
305
    {
306
        $this->bodyLocArgs = $bodyLocArgs;
307
308
        return $this;
309
    }
310
311
    /**
312
     * @return string|null
313
     */
314
    public function getTitleLocKey(): ?string
315
    {
316
        return $this->titleLocKey;
317
    }
318
319
    /**
320
     * @param string|null $titleLocKey
321
     * @return AndroidNotification
322
     */
323
    public function setTitleLocKey(?string $titleLocKey): self
324
    {
325
        $this->titleLocKey = $titleLocKey;
326
327
        return $this;
328
    }
329
330
    /**
331
     * @return string[]|null
332
     */
333
    public function getTitleLocArgs(): ?array
334
    {
335
        return $this->titleLocArgs;
336
    }
337
338
    /**
339
     * @param string[]|null $titleLocArgs
340
     * @return AndroidNotification
341
     */
342
    public function setTitleLocArgs(?array $titleLocArgs): self
343
    {
344
        $this->titleLocArgs = $titleLocArgs;
345
346
        return $this;
347
    }
348
349
    /**
350
     * @return string|null
351
     */
352
    public function getChannelId(): ?string
353
    {
354
        return $this->channelId;
355
    }
356
357
    /**
358
     * @param string|null $channelId
359
     * @return AndroidNotification
360
     */
361
    public function setChannelId(?string $channelId): self
362
    {
363
        $this->channelId = $channelId;
364
365
        return $this;
366
    }
367
368
    /**
369
     * @return string|null
370
     */
371
    public function getTicker(): ?string
372
    {
373
        return $this->ticker;
374
    }
375
376
    /**
377
     * @param string|null $ticker
378
     * @return AndroidNotification
379
     */
380
    public function setTicker(?string $ticker): self
381
    {
382
        $this->ticker = $ticker;
383
384
        return $this;
385
    }
386
387
    /**
388
     * @return bool|null
389
     */
390
    public function getSticky(): ?bool
391
    {
392
        return $this->sticky;
393
    }
394
395
    /**
396
     * @param bool|null $sticky
397
     * @return AndroidNotification
398
     */
399
    public function setSticky(?bool $sticky): self
400
    {
401
        $this->sticky = $sticky;
402
403
        return $this;
404
    }
405
406
    /**
407
     * @return string|null
408
     */
409
    public function getEventTime(): ?string
410
    {
411
        return $this->eventTime;
412
    }
413
414
    /**
415
     * @param string|null $eventTime
416
     * @return AndroidNotification
417
     */
418
    public function setEventTime(?string $eventTime): self
419
    {
420
        $this->eventTime = $eventTime;
421
422
        return $this;
423
    }
424
425
    /**
426
     * @return bool|null
427
     */
428
    public function getLocalOnly(): ?bool
429
    {
430
        return $this->localOnly;
431
    }
432
433
    /**
434
     * @param bool|null $localOnly
435
     * @return AndroidNotification
436
     */
437
    public function setLocalOnly(?bool $localOnly): self
438
    {
439
        $this->localOnly = $localOnly;
440
441
        return $this;
442
    }
443
444
    /**
445
     * @return NotificationPriority|null
446
     */
447
    public function getNotificationPriority(): ?NotificationPriority
448
    {
449
        return $this->notificationPriority;
450
    }
451
452
    /**
453
     * @param NotificationPriority|null $notificationPriority
454
     * @return AndroidNotification
455
     */
456
    public function setNotificationPriority(?NotificationPriority $notificationPriority): self
457
    {
458
        $this->notificationPriority = $notificationPriority;
459
460
        return $this;
461
    }
462
463
    /**
464
     * @return bool|null
465
     */
466
    public function getDefaultSound(): ?bool
467
    {
468
        return $this->defaultSound;
469
    }
470
471
    /**
472
     * @param bool|null $defaultSound
473
     * @return AndroidNotification
474
     */
475
    public function setDefaultSound(?bool $defaultSound): self
476
    {
477
        $this->defaultSound = $defaultSound;
478
479
        return $this;
480
    }
481
482
    /**
483
     * @return bool|null
484
     */
485
    public function getDefaultVibrateTimings(): ?bool
486
    {
487
        return $this->defaultVibrateTimings;
488
    }
489
490
    /**
491
     * @param bool|null $defaultVibrateTimings
492
     * @return AndroidNotification
493
     */
494
    public function setDefaultVibrateTimings(?bool $defaultVibrateTimings): self
495
    {
496
        $this->defaultVibrateTimings = $defaultVibrateTimings;
497
498
        return $this;
499
    }
500
501
    /**
502
     * @return bool|null
503
     */
504
    public function getDefaultLightSettings(): ?bool
505
    {
506
        return $this->defaultLightSettings;
507
    }
508
509
    /**
510
     * @param bool|null $defaultLightSettings
511
     * @return AndroidNotification
512
     */
513
    public function setDefaultLightSettings(?bool $defaultLightSettings): self
514
    {
515
        $this->defaultLightSettings = $defaultLightSettings;
516
517
        return $this;
518
    }
519
520
    /**
521
     * @return string[]|null
522
     */
523
    public function getVibrateTimings(): ?array
524
    {
525
        return $this->vibrateTimings;
526
    }
527
528
    /**
529
     * @param string[]|null $vibrateTimings
530
     * @return AndroidNotification
531
     */
532
    public function setVibrateTimings(?array $vibrateTimings): self
533
    {
534
        $this->vibrateTimings = $vibrateTimings;
535
536
        return $this;
537
    }
538
539
    /**
540
     * @return Visibility|null
541
     */
542
    public function getVisibility(): ?Visibility
543
    {
544
        return $this->visibility;
545
    }
546
547
    /**
548
     * @param Visibility|null $visibility
549
     * @return AndroidNotification
550
     */
551
    public function setVisibility(?Visibility $visibility): self
552
    {
553
        $this->visibility = $visibility;
554
555
        return $this;
556
    }
557
558
    /**
559
     * @return int|null
560
     */
561
    public function getNotificationCount(): ?int
562
    {
563
        return $this->notificationCount;
564
    }
565
566
    /**
567
     * @param int|null $notificationCount
568
     * @return AndroidNotification
569
     */
570
    public function setNotificationCount(?int $notificationCount): self
571
    {
572
        $this->notificationCount = $notificationCount;
573
574
        return $this;
575
    }
576
577
    /**
578
     * @return LightSettings|null
579
     */
580
    public function getLightSettings(): ?LightSettings
581
    {
582
        return $this->lightSettings;
583
    }
584
585
    /**
586
     * @param LightSettings|null $lightSettings
587
     * @return AndroidNotification
588
     */
589
    public function setLightSettings(?LightSettings $lightSettings): self
590
    {
591
        $this->lightSettings = $lightSettings;
592
593
        return $this;
594
    }
595
596
    /**
597
     * @return string|null
598
     */
599
    public function getImage(): ?string
600
    {
601
        return $this->image;
602
    }
603
604
    /**
605
     * @param string|null $image
606
     * @return AndroidNotification
607
     */
608
    public function setImage(?string $image): self
609
    {
610
        $this->image = $image;
611
612
        return $this;
613
    }
614
615
    /**
616
     * {@inheritdoc}
617
     */
618
    public function toArray(): array
619
    {
620
        return [
621
            'title' => $this->getTitle(),
622
            'body' => $this->getBody(),
623
            'icon' => $this->getIcon(),
624
            'color' => $this->getColor(),
625
            'sound' => $this->getSound(),
626
            'tag' => $this->getTag(),
627
            'click_action' => $this->getClickAction(),
628
            'body_loc_key' => $this->getBodyLocKey(),
629
            'body_loc_args' => $this->getBodyLocArgs(),
630
            'title_loc_key' => $this->getTitleLocKey(),
631
            'title_loc_args' => $this->getTitleLocArgs(),
632
            'channel_id' => $this->getChannelId(),
633
            'ticker' => $this->getTicker(),
634
            'sticky' => $this->getSticky(),
635
            'event_time' => $this->getEventTime(),
636
            'local_only' => $this->getLocalOnly(),
637
            'notification_priority' => ! is_null($this->getNotificationPriority()) ? $this->getNotificationPriority()->getValue() : null,
638
            'default_sound' => $this->getDefaultSound(),
639
            'default_vibrate_timings' => $this->getDefaultVibrateTimings(),
640
            'default_light_settings' => $this->getDefaultLightSettings(),
641
            'vibrate_timings' => $this->getVibrateTimings(),
642
            'visibility' => ! is_null($this->getVisibility()) ? $this->getVisibility()->getValue() : null,
643
            'notification_count' => $this->getNotificationCount(),
644
            //'light_setings' => ! is_null($this->getLightSettings()) ? $this->getLightSettings()->toArray() : null,
645
            'image' => $this->getImage(),
646
        ];
647
    }
648
}
649