Notification::setCollapseId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Pushok package.
5
 *
6
 * (c) Arthur Edamov <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Pushok;
13
14
use DateTime;
15
16
/**
17
 * Class Notification
18
 * @package Pushok
19
 */
20
class Notification
21
{
22
    const PRIORITY_HIGH = 10;
23
    const PRIORITY_LOW = 5;
24
25
    /**
26
     * Notification payload.
27
     *
28
     * @var Payload
29
     */
30
    private $payload;
31
32
    /**
33
     * Token of device.
34
     *
35
     * @var string
36
     */
37
    private $deviceToken;
38
39
    /**
40
     * A canonical UUID that identifies the notification.
41
     *
42
     * @var string
43
     */
44
    private $id;
45
46
    /**
47
     * This value identifies the date when the notification is no longer valid and can be discarded.
48
     *
49
     * @var DateTime
50
     */
51
    private $expirationAt;
52
53
    /**
54
     * The priority of the notification.
55
     *
56
     * @var int
57
     */
58
    private $priority;
59
60
    /**
61
     * Id for the coalescing of similar notifications.
62
     *
63
     * @var string
64
     */
65
    private $collapseId;
66
67
    /**
68
     * Notification constructor.
69
     *
70
     * @param Payload $payload
71
     * @param string $deviceToken
72
     */
73
    public function __construct(Payload $payload, string $deviceToken)
74
    {
75
        $this->payload = $payload;
76
        $this->deviceToken = $deviceToken;
77
    }
78
79
    /**
80
     * Get device token.
81
     *
82
     * @return string
83
     */
84
    public function getDeviceToken(): string
85
    {
86
        return $this->deviceToken;
87
    }
88
89
    /**
90
     * Get payload.
91
     *
92
     * @return Payload
93
     */
94
    public function getPayload(): Payload
95
    {
96
        return $this->payload;
97
    }
98
99
    /**
100
     * Get notification id.
101
     *
102
     * @return string|null
103
     */
104
    public function getId()
105
    {
106
        return $this->id;
107
    }
108
109
    /**
110
     * Set notification id.
111
     *
112
     * @param string $id
113
     * @return Notification
114
     */
115
    public function setId(string $id): Notification
116
    {
117
        $this->id = $id;
118
119
        return $this;
120
    }
121
122
    /**
123
     * Get expiration DateTime.
124
     *
125
     * @return DateTime|null
126
     */
127
    public function getExpirationAt(): ?DateTime
128
    {
129
        return $this->expirationAt;
130
    }
131
132
    /**
133
     * Set expiration DateTime.
134
     *
135
     * @param DateTime $expirationAt
136
     * @return Notification
137
     */
138
    public function setExpirationAt(DateTime $expirationAt): Notification
139
    {
140
        $this->expirationAt = clone $expirationAt;
141
142
        return $this;
143
    }
144
145
    /**
146
     * Get notification priority.
147
     *
148
     * @return int|null
149
     */
150
    public function getPriority()
151
    {
152
        return $this->priority;
153
    }
154
155
    /**
156
     * Set high priority.
157
     *
158
     * @return Notification
159
     */
160
    public function setHighPriority(): Notification
161
    {
162
        $this->priority = self::PRIORITY_HIGH;
163
164
        return $this;
165
    }
166
167
    /**
168
     * Set low priority.
169
     *
170
     * @return Notification
171
     */
172
    public function setLowPriority(): Notification
173
    {
174
        $this->priority = self::PRIORITY_LOW;
175
176
        return $this;
177
    }
178
179
    /**
180
     * @return string|null
181
     */
182
    public function getCollapseId()
183
    {
184
        return $this->collapseId;
185
    }
186
187
    /**
188
     * @param string $collapseId
189
     * @return Notification
190
     */
191
    public function setCollapseId(string $collapseId): Notification
192
    {
193
        $this->collapseId = $collapseId;
194
195
        return $this;
196
    }
197
}
198