forked from symfony/firebase-notifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirebaseOptions.php
More file actions
92 lines (75 loc) · 1.87 KB
/
FirebaseOptions.php
File metadata and controls
92 lines (75 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Notifier\Bridge\Firebase;
use Symfony\Component\Notifier\Message\MessageOptionsInterface;
/**
* @author Jeroen Spee <https://github.com/Jeroeny>
*
* @see https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages
*/
abstract class FirebaseOptions implements MessageOptionsInterface
{
private string $topic;
/**
* @see https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages
*/
protected array $options;
private array $data;
public function __construct(string $topic, array $options, array $data = [])
{
$this->topic = $topic;
$this->options = $options;
$this->data = $data;
}
public function toArray(): array
{
return [
'topic' => $this->topic,
'notification' => $this->options,
'data' => $this->data,
];
}
public function getRecipientId(): ?string
{
return $this->topic;
}
/**
* @return $this
*/
public function title(string $title): static
{
$this->options['title'] = $title;
return $this;
}
/**
* @return $this
*/
public function body(string $body): static
{
$this->options['body'] = $body;
return $this;
}
/**
* @return $this
*/
public function sendNotification(bool $sendNotification = true): static
{
$this->options['sendNotification'] = $sendNotification;
return $this;
}
/**
* @return $this
*/
public function data(array $data): static
{
$this->data = $data;
return $this;
}
}