/
FirebaseOptions.php
67 lines (55 loc) · 1.41 KB
/
FirebaseOptions.php
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
<?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/cloud-messaging/xmpp-server-ref.html
*
* @experimental in 5.1
*/
abstract class FirebaseOptions implements MessageOptionsInterface
{
/** @var string the recipient */
private $to;
/**
* @var array
*
* @see https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref.html#notification-payload-support
*/
protected $options;
public function __construct(string $to, array $options)
{
$this->to = $to;
$this->options = $options;
}
public function toArray(): array
{
return [
'to' => $this->to,
'notification' => $this->options,
];
}
public function getRecipientId(): ?string
{
return $this->to;
}
public function title(string $title): self
{
$this->options['title'] = $title;
return $this;
}
public function body(string $body): self
{
$this->options['body'] = $body;
return $this;
}
}