1
<?php
2

3
declare(strict_types=1);
4

5
namespace Kreait\Firebase\Messaging;
6

7
use DateTimeImmutable;
8
use JsonSerializable;
9

10
final class TopicSubscription implements JsonSerializable
11
{
12
    /** @var Topic */
13
    private $topic;
14

15
    /** @var RegistrationToken */
16
    private $registrationToken;
17

18
    /** @var DateTimeImmutable */
19
    private $subscribedAt;
20

21 12
    public function __construct(Topic $topic, RegistrationToken $registrationToken, DateTimeImmutable $subscribedAt)
22
    {
23 12
        $this->topic = $topic;
24 12
        $this->registrationToken = $registrationToken;
25 12
        $this->subscribedAt = $subscribedAt;
26
    }
27

28 3
    public function topic(): Topic
29
    {
30 3
        return $this->topic;
31
    }
32

33 0
    public function registrationToken(): RegistrationToken
34
    {
35 0
        return $this->registrationToken;
36
    }
37

38 3
    public function subscribedAt(): DateTimeImmutable
39
    {
40 3
        return $this->subscribedAt;
41
    }
42

43
    /**
44
     * @return array<string, string>
45
     */
46 0
    public function jsonSerialize(): array
47
    {
48
        return [
49 0
            'topic' => $this->topic->value(),
50 0
            'registration_token' => $this->registrationToken->value(),
51 0
            'subscribed_at' => $this->subscribedAt->format(\DATE_ATOM),
52
        ];
53
    }
54
}

Read our documentation on viewing source code .

Loading