Completed
Push — master ( 1d9715...e57dba )
by Vitaliy
14s
created

Notification::getExpiration()   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
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the AppleApnPush package
7
 *
8
 * (c) Vitaliy Zhuk <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace Apple\ApnPush\Model;
15
16
/**
17
 * Send this notification to device.
18
 */
19
class Notification
20
{
21
    /**
22
     * @var Payload
23
     */
24
    private $payload;
25
26
    /**
27
     * @var ApnId
28
     */
29
    private $apnId;
30
31
    /**
32
     * @var Priority
33
     */
34
    private $priority;
35
36
    /**
37
     * @var Expiration
38
     */
39
    private $expiration;
40
41
    /**
42
     * @var CollapseId
43
     */
44
    private $collapseId;
45
46
    /**
47
     * Constructor.
48
     *
49
     * @param Payload         $payload
50
     * @param ApnId|null      $apnId
51
     * @param Priority|null   $priority
52
     * @param Expiration|null $expiration
53
     * @param CollapseId|null $collapseId
54
     */
55
    public function __construct(
56
        Payload $payload,
57
        ApnId $apnId = null,
58
        Priority $priority = null,
59
        Expiration $expiration = null,
60
        CollapseId $collapseId = null
61
    ) {
62
        $this->payload = $payload;
63
        $this->priority = $priority;
64
        $this->apnId = $apnId;
65
        $this->expiration = $expiration;
66
        $this->collapseId = $collapseId;
67
    }
68
69
    /**
70
     * Create new notification with body only
71
     *
72
     * @param string $body
73
     *
74
     * @return Notification
75
     */
76
    public static function createWithBody(string $body): Notification
77
    {
78
        return new self(Payload::createWithBody($body));
79
    }
80
81
    /**
82
     * Set payload
83
     *
84
     * @param Payload $payload
85
     *
86
     * @return Notification
87
     */
88
    public function withPayload(Payload $payload): Notification
89
    {
90
        $cloned = clone $this;
91
92
        $cloned->payload = $payload;
93
94
        return $cloned;
95
    }
96
97
    /**
98
     * Get payload
99
     *
100
     * @return Payload
101
     */
102
    public function getPayload(): Payload
103
    {
104
        return $this->payload;
105
    }
106
107
    /**
108
     * Set apn identifier
109
     *
110
     * @param ApnId $apnId
111
     *
112
     * @return Notification
113
     */
114
    public function withApnId(ApnId $apnId = null): Notification
115
    {
116
        $cloned = clone $this;
117
118
        $cloned->apnId = $apnId;
119
120
        return $cloned;
121
    }
122
123
    /**
124
     * Get identifier of notification
125
     *
126
     * @return ApnId
127
     */
128
    public function getApnId(): ?ApnId
129
    {
130
        return $this->apnId;
131
    }
132
133
    /**
134
     * Set priority
135
     *
136
     * @param Priority $priority
137
     *
138
     * @return Notification
139
     */
140
    public function withPriority(Priority $priority = null): Notification
141
    {
142
        $cloned = clone $this;
143
144
        $cloned->priority = $priority;
145
146
        return $cloned;
147
    }
148
149
    /**
150
     * Get priority
151
     *
152
     * @return Priority
153
     */
154
    public function getPriority(): ?Priority
155
    {
156
        return $this->priority;
157
    }
158
159
    /**
160
     * Set expiration
161
     *
162
     * @param Expiration $expiration
163
     *
164
     * @return Notification
165
     */
166
    public function withExpiration(Expiration $expiration = null): Notification
167
    {
168
        $cloned = clone $this;
169
170
        $cloned->expiration = $expiration;
171
172
        return $cloned;
173
    }
174
175
    /**
176
     * Get expiration
177
     *
178
     * @return Expiration
179
     */
180
    public function getExpiration(): ?Expiration
181
    {
182
        return $this->expiration;
183
    }
184
185
    /**
186
     * Set the collapse identifier
187
     *
188
     * @param CollapseId|null $collapseId
189
     *
190
     * @return Notification
191
     */
192
    public function withCollapseId(CollapseId $collapseId = null): Notification
193
    {
194
        $cloned = clone $this;
195
196
        $cloned->collapseId = $collapseId;
197
198
        return $cloned;
199
    }
200
201
    /**
202
     * Get the collapse identifier
203
     *
204
     * @return CollapseId|null
205
     */
206
    public function getCollapseId(): ?CollapseId
207
    {
208
        return $this->collapseId;
209
    }
210
}
211