Completed
Push — master ( 9b760e...8a0b19 )
by Arthur
01:59
created

Notification::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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