Passed
Push — master ( 857676...bf18f1 )
by John
14:23
created
lib/public/Notification/INotification.php 1 patch
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -31,294 +31,294 @@
 block discarded – undo
31 31
  * @since 9.0.0
32 32
  */
33 33
 interface INotification {
34
-	/**
35
-	 * @param string $app
36
-	 * @return $this
37
-	 * @throws \InvalidArgumentException if the app id is invalid
38
-	 * @since 9.0.0
39
-	 */
40
-	public function setApp(string $app);
41
-
42
-	/**
43
-	 * @return string
44
-	 * @since 9.0.0
45
-	 */
46
-	public function getApp();
47
-
48
-	/**
49
-	 * @param string $user
50
-	 * @return $this
51
-	 * @throws \InvalidArgumentException if the user id is invalid
52
-	 * @since 9.0.0
53
-	 */
54
-	public function setUser(string $user);
55
-
56
-	/**
57
-	 * @return string
58
-	 * @since 9.0.0
59
-	 */
60
-	public function getUser();
61
-
62
-	/**
63
-	 * @param \DateTime $dateTime
64
-	 * @return $this
65
-	 * @throws \InvalidArgumentException if the $dateTime is invalid
66
-	 * @since 9.0.0
67
-	 */
68
-	public function setDateTime(\DateTime $dateTime);
69
-
70
-	/**
71
-	 * @return \DateTime
72
-	 * @since 9.0.0
73
-	 */
74
-	public function getDateTime();
75
-
76
-	/**
77
-	 * @param string $type
78
-	 * @param string $id
79
-	 * @return $this
80
-	 * @throws \InvalidArgumentException if the object type or id is invalid
81
-	 * @since 9.0.0
82
-	 */
83
-	public function setObject(string $type, $id);
84
-
85
-	/**
86
-	 * @return string
87
-	 * @since 9.0.0
88
-	 */
89
-	public function getObjectType();
90
-
91
-	/**
92
-	 * @return string
93
-	 * @since 9.0.0
94
-	 */
95
-	public function getObjectId();
96
-
97
-	/**
98
-	 * @param string $subject
99
-	 * @param array $parameters
100
-	 * @return $this
101
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
102
-	 * @since 9.0.0
103
-	 */
104
-	public function setSubject(string $subject, array $parameters = []);
105
-
106
-	/**
107
-	 * @return string
108
-	 * @since 9.0.0
109
-	 */
110
-	public function getSubject();
111
-
112
-	/**
113
-	 * @return string[]
114
-	 * @since 9.0.0
115
-	 */
116
-	public function getSubjectParameters();
117
-
118
-	/**
119
-	 * Set a parsed subject
120
-	 *
121
-	 * HTML is not allowed in the parsed subject and will be escaped
122
-	 * automatically by the clients. You can use the RichObjectString system
123
-	 * provided by the Nextcloud server to highlight important parameters via
124
-	 * the setRichSubject method, but make sure, that a plain text message is
125
-	 * always set via setParsedSubject, to support clients which can not handle
126
-	 * rich strings.
127
-	 *
128
-	 * See https://github.com/nextcloud/server/issues/1706 for more information.
129
-	 *
130
-	 * @param string $subject
131
-	 * @return $this
132
-	 * @throws \InvalidArgumentException if the subject is invalid
133
-	 * @since 9.0.0
134
-	 */
135
-	public function setParsedSubject(string $subject);
136
-
137
-	/**
138
-	 * @return string
139
-	 * @since 9.0.0
140
-	 */
141
-	public function getParsedSubject();
142
-
143
-	/**
144
-	 * Set a RichObjectString subject
145
-	 *
146
-	 * HTML is not allowed in the rich subject and will be escaped automatically
147
-	 * by the clients, but you can use the RichObjectString system provided by
148
-	 * the Nextcloud server to highlight important parameters.
149
-	 * Also make sure, that a plain text subject is always set via
150
-	 * setParsedSubject, to support clients which can not handle rich strings.
151
-	 *
152
-	 * See https://github.com/nextcloud/server/issues/1706 for more information.
153
-	 *
154
-	 * @param string $subject
155
-	 * @param array $parameters
156
-	 * @return $this
157
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
158
-	 * @since 11.0.0
159
-	 */
160
-	public function setRichSubject(string $subject, array $parameters = []);
161
-
162
-	/**
163
-	 * @return string
164
-	 * @since 11.0.0
165
-	 */
166
-	public function getRichSubject();
167
-
168
-	/**
169
-	 * @return array[]
170
-	 * @since 11.0.0
171
-	 */
172
-	public function getRichSubjectParameters();
173
-
174
-	/**
175
-	 * @param string $message
176
-	 * @param array $parameters
177
-	 * @return $this
178
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
179
-	 * @since 9.0.0
180
-	 */
181
-	public function setMessage(string $message, array $parameters = []);
182
-
183
-	/**
184
-	 * @return string
185
-	 * @since 9.0.0
186
-	 */
187
-	public function getMessage();
188
-
189
-	/**
190
-	 * @return string[]
191
-	 * @since 9.0.0
192
-	 */
193
-	public function getMessageParameters();
194
-
195
-	/**
196
-	 * Set a parsed message
197
-	 *
198
-	 * HTML is not allowed in the parsed message and will be escaped
199
-	 * automatically by the clients. You can use the RichObjectString system
200
-	 * provided by the Nextcloud server to highlight important parameters via
201
-	 * the setRichMessage method, but make sure, that a plain text message is
202
-	 * always set via setParsedMessage, to support clients which can not handle
203
-	 * rich strings.
204
-	 *
205
-	 * See https://github.com/nextcloud/server/issues/1706 for more information.
206
-	 *
207
-	 * @param string $message
208
-	 * @return $this
209
-	 * @throws \InvalidArgumentException if the message is invalid
210
-	 * @since 9.0.0
211
-	 */
212
-	public function setParsedMessage(string $message);
213
-
214
-	/**
215
-	 * @return string
216
-	 * @since 9.0.0
217
-	 */
218
-	public function getParsedMessage();
219
-
220
-	/**
221
-	 * Set a RichObjectString message
222
-	 *
223
-	 * HTML is not allowed in the rich message and will be escaped automatically
224
-	 * by the clients, but you can use the RichObjectString system provided by
225
-	 * the Nextcloud server to highlight important parameters.
226
-	 * Also make sure, that a plain text message is always set via
227
-	 * setParsedMessage, to support clients which can not handle rich strings.
228
-	 *
229
-	 * See https://github.com/nextcloud/server/issues/1706 for more information.
230
-	 *
231
-	 * @param string $message
232
-	 * @param array $parameters
233
-	 * @return $this
234
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
235
-	 * @since 11.0.0
236
-	 */
237
-	public function setRichMessage(string $message, array $parameters = []);
238
-
239
-	/**
240
-	 * @return string
241
-	 * @since 11.0.0
242
-	 */
243
-	public function getRichMessage();
244
-
245
-	/**
246
-	 * @return array[]
247
-	 * @since 11.0.0
248
-	 */
249
-	public function getRichMessageParameters();
250
-
251
-	/**
252
-	 * @param string $link
253
-	 * @return $this
254
-	 * @throws \InvalidArgumentException if the link is invalid
255
-	 * @since 9.0.0
256
-	 */
257
-	public function setLink(string $link);
258
-
259
-	/**
260
-	 * @return string
261
-	 * @since 9.0.0
262
-	 */
263
-	public function getLink();
264
-
265
-	/**
266
-	 * @param string $icon
267
-	 * @return $this
268
-	 * @throws \InvalidArgumentException if the icon is invalid
269
-	 * @since 11.0.0
270
-	 */
271
-	public function setIcon(string $icon);
272
-
273
-	/**
274
-	 * @return string
275
-	 * @since 11.0.0
276
-	 */
277
-	public function getIcon();
278
-
279
-	/**
280
-	 * @return IAction
281
-	 * @since 9.0.0
282
-	 */
283
-	public function createAction();
284
-
285
-	/**
286
-	 * @param IAction $action
287
-	 * @return $this
288
-	 * @throws \InvalidArgumentException if the action is invalid
289
-	 * @since 9.0.0
290
-	 */
291
-	public function addAction(IAction $action);
292
-
293
-	/**
294
-	 * @return IAction[]
295
-	 * @since 9.0.0
296
-	 */
297
-	public function getActions();
298
-
299
-	/**
300
-	 * @param IAction $action
301
-	 * @return $this
302
-	 * @throws \InvalidArgumentException if the action is invalid
303
-	 * @since 9.0.0
304
-	 */
305
-	public function addParsedAction(IAction $action);
306
-
307
-	/**
308
-	 * @return IAction[]
309
-	 * @since 9.0.0
310
-	 */
311
-	public function getParsedActions();
312
-
313
-	/**
314
-	 * @return bool
315
-	 * @since 9.0.0
316
-	 */
317
-	public function isValid();
318
-
319
-	/**
320
-	 * @return bool
321
-	 * @since 9.0.0
322
-	 */
323
-	public function isValidParsed();
34
+    /**
35
+     * @param string $app
36
+     * @return $this
37
+     * @throws \InvalidArgumentException if the app id is invalid
38
+     * @since 9.0.0
39
+     */
40
+    public function setApp(string $app);
41
+
42
+    /**
43
+     * @return string
44
+     * @since 9.0.0
45
+     */
46
+    public function getApp();
47
+
48
+    /**
49
+     * @param string $user
50
+     * @return $this
51
+     * @throws \InvalidArgumentException if the user id is invalid
52
+     * @since 9.0.0
53
+     */
54
+    public function setUser(string $user);
55
+
56
+    /**
57
+     * @return string
58
+     * @since 9.0.0
59
+     */
60
+    public function getUser();
61
+
62
+    /**
63
+     * @param \DateTime $dateTime
64
+     * @return $this
65
+     * @throws \InvalidArgumentException if the $dateTime is invalid
66
+     * @since 9.0.0
67
+     */
68
+    public function setDateTime(\DateTime $dateTime);
69
+
70
+    /**
71
+     * @return \DateTime
72
+     * @since 9.0.0
73
+     */
74
+    public function getDateTime();
75
+
76
+    /**
77
+     * @param string $type
78
+     * @param string $id
79
+     * @return $this
80
+     * @throws \InvalidArgumentException if the object type or id is invalid
81
+     * @since 9.0.0
82
+     */
83
+    public function setObject(string $type, $id);
84
+
85
+    /**
86
+     * @return string
87
+     * @since 9.0.0
88
+     */
89
+    public function getObjectType();
90
+
91
+    /**
92
+     * @return string
93
+     * @since 9.0.0
94
+     */
95
+    public function getObjectId();
96
+
97
+    /**
98
+     * @param string $subject
99
+     * @param array $parameters
100
+     * @return $this
101
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
102
+     * @since 9.0.0
103
+     */
104
+    public function setSubject(string $subject, array $parameters = []);
105
+
106
+    /**
107
+     * @return string
108
+     * @since 9.0.0
109
+     */
110
+    public function getSubject();
111
+
112
+    /**
113
+     * @return string[]
114
+     * @since 9.0.0
115
+     */
116
+    public function getSubjectParameters();
117
+
118
+    /**
119
+     * Set a parsed subject
120
+     *
121
+     * HTML is not allowed in the parsed subject and will be escaped
122
+     * automatically by the clients. You can use the RichObjectString system
123
+     * provided by the Nextcloud server to highlight important parameters via
124
+     * the setRichSubject method, but make sure, that a plain text message is
125
+     * always set via setParsedSubject, to support clients which can not handle
126
+     * rich strings.
127
+     *
128
+     * See https://github.com/nextcloud/server/issues/1706 for more information.
129
+     *
130
+     * @param string $subject
131
+     * @return $this
132
+     * @throws \InvalidArgumentException if the subject is invalid
133
+     * @since 9.0.0
134
+     */
135
+    public function setParsedSubject(string $subject);
136
+
137
+    /**
138
+     * @return string
139
+     * @since 9.0.0
140
+     */
141
+    public function getParsedSubject();
142
+
143
+    /**
144
+     * Set a RichObjectString subject
145
+     *
146
+     * HTML is not allowed in the rich subject and will be escaped automatically
147
+     * by the clients, but you can use the RichObjectString system provided by
148
+     * the Nextcloud server to highlight important parameters.
149
+     * Also make sure, that a plain text subject is always set via
150
+     * setParsedSubject, to support clients which can not handle rich strings.
151
+     *
152
+     * See https://github.com/nextcloud/server/issues/1706 for more information.
153
+     *
154
+     * @param string $subject
155
+     * @param array $parameters
156
+     * @return $this
157
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
158
+     * @since 11.0.0
159
+     */
160
+    public function setRichSubject(string $subject, array $parameters = []);
161
+
162
+    /**
163
+     * @return string
164
+     * @since 11.0.0
165
+     */
166
+    public function getRichSubject();
167
+
168
+    /**
169
+     * @return array[]
170
+     * @since 11.0.0
171
+     */
172
+    public function getRichSubjectParameters();
173
+
174
+    /**
175
+     * @param string $message
176
+     * @param array $parameters
177
+     * @return $this
178
+     * @throws \InvalidArgumentException if the message or parameters are invalid
179
+     * @since 9.0.0
180
+     */
181
+    public function setMessage(string $message, array $parameters = []);
182
+
183
+    /**
184
+     * @return string
185
+     * @since 9.0.0
186
+     */
187
+    public function getMessage();
188
+
189
+    /**
190
+     * @return string[]
191
+     * @since 9.0.0
192
+     */
193
+    public function getMessageParameters();
194
+
195
+    /**
196
+     * Set a parsed message
197
+     *
198
+     * HTML is not allowed in the parsed message and will be escaped
199
+     * automatically by the clients. You can use the RichObjectString system
200
+     * provided by the Nextcloud server to highlight important parameters via
201
+     * the setRichMessage method, but make sure, that a plain text message is
202
+     * always set via setParsedMessage, to support clients which can not handle
203
+     * rich strings.
204
+     *
205
+     * See https://github.com/nextcloud/server/issues/1706 for more information.
206
+     *
207
+     * @param string $message
208
+     * @return $this
209
+     * @throws \InvalidArgumentException if the message is invalid
210
+     * @since 9.0.0
211
+     */
212
+    public function setParsedMessage(string $message);
213
+
214
+    /**
215
+     * @return string
216
+     * @since 9.0.0
217
+     */
218
+    public function getParsedMessage();
219
+
220
+    /**
221
+     * Set a RichObjectString message
222
+     *
223
+     * HTML is not allowed in the rich message and will be escaped automatically
224
+     * by the clients, but you can use the RichObjectString system provided by
225
+     * the Nextcloud server to highlight important parameters.
226
+     * Also make sure, that a plain text message is always set via
227
+     * setParsedMessage, to support clients which can not handle rich strings.
228
+     *
229
+     * See https://github.com/nextcloud/server/issues/1706 for more information.
230
+     *
231
+     * @param string $message
232
+     * @param array $parameters
233
+     * @return $this
234
+     * @throws \InvalidArgumentException if the message or parameters are invalid
235
+     * @since 11.0.0
236
+     */
237
+    public function setRichMessage(string $message, array $parameters = []);
238
+
239
+    /**
240
+     * @return string
241
+     * @since 11.0.0
242
+     */
243
+    public function getRichMessage();
244
+
245
+    /**
246
+     * @return array[]
247
+     * @since 11.0.0
248
+     */
249
+    public function getRichMessageParameters();
250
+
251
+    /**
252
+     * @param string $link
253
+     * @return $this
254
+     * @throws \InvalidArgumentException if the link is invalid
255
+     * @since 9.0.0
256
+     */
257
+    public function setLink(string $link);
258
+
259
+    /**
260
+     * @return string
261
+     * @since 9.0.0
262
+     */
263
+    public function getLink();
264
+
265
+    /**
266
+     * @param string $icon
267
+     * @return $this
268
+     * @throws \InvalidArgumentException if the icon is invalid
269
+     * @since 11.0.0
270
+     */
271
+    public function setIcon(string $icon);
272
+
273
+    /**
274
+     * @return string
275
+     * @since 11.0.0
276
+     */
277
+    public function getIcon();
278
+
279
+    /**
280
+     * @return IAction
281
+     * @since 9.0.0
282
+     */
283
+    public function createAction();
284
+
285
+    /**
286
+     * @param IAction $action
287
+     * @return $this
288
+     * @throws \InvalidArgumentException if the action is invalid
289
+     * @since 9.0.0
290
+     */
291
+    public function addAction(IAction $action);
292
+
293
+    /**
294
+     * @return IAction[]
295
+     * @since 9.0.0
296
+     */
297
+    public function getActions();
298
+
299
+    /**
300
+     * @param IAction $action
301
+     * @return $this
302
+     * @throws \InvalidArgumentException if the action is invalid
303
+     * @since 9.0.0
304
+     */
305
+    public function addParsedAction(IAction $action);
306
+
307
+    /**
308
+     * @return IAction[]
309
+     * @since 9.0.0
310
+     */
311
+    public function getParsedActions();
312
+
313
+    /**
314
+     * @return bool
315
+     * @since 9.0.0
316
+     */
317
+    public function isValid();
318
+
319
+    /**
320
+     * @return bool
321
+     * @since 9.0.0
322
+     */
323
+    public function isValidParsed();
324 324
 }
Please login to merge, or discard this patch.
lib/private/Notification/Notification.php 1 patch
Indentation   +551 added lines, -551 removed lines patch added patch discarded remove patch
@@ -33,555 +33,555 @@
 block discarded – undo
33 33
 
34 34
 class Notification implements INotification {
35 35
 
36
-	/** @var IValidator */
37
-	protected $richValidator;
38
-
39
-	/** @var string */
40
-	protected $app;
41
-
42
-	/** @var string */
43
-	protected $user;
44
-
45
-	/** @var \DateTime */
46
-	protected $dateTime;
47
-
48
-	/** @var string */
49
-	protected $objectType;
50
-
51
-	/** @var string */
52
-	protected $objectId;
53
-
54
-	/** @var string */
55
-	protected $subject;
56
-
57
-	/** @var array */
58
-	protected $subjectParameters;
59
-
60
-	/** @var string */
61
-	protected $subjectParsed;
62
-
63
-	/** @var string */
64
-	protected $subjectRich;
65
-
66
-	/** @var array */
67
-	protected $subjectRichParameters;
68
-
69
-	/** @var string */
70
-	protected $message;
71
-
72
-	/** @var array */
73
-	protected $messageParameters;
74
-
75
-	/** @var string */
76
-	protected $messageParsed;
77
-
78
-	/** @var string */
79
-	protected $messageRich;
80
-
81
-	/** @var array */
82
-	protected $messageRichParameters;
83
-
84
-	/** @var string */
85
-	protected $link;
86
-
87
-	/** @var string */
88
-	protected $icon;
89
-
90
-	/** @var array */
91
-	protected $actions;
92
-
93
-	/** @var array */
94
-	protected $actionsParsed;
95
-
96
-	/** @var bool */
97
-	protected $hasPrimaryAction;
98
-
99
-	/** @var bool */
100
-	protected $hasPrimaryParsedAction;
101
-
102
-	/**
103
-	 * Constructor
104
-	 *
105
-	 * @param IValidator $richValidator
106
-	 */
107
-	public function __construct(IValidator $richValidator) {
108
-		$this->richValidator = $richValidator;
109
-		$this->app = '';
110
-		$this->user = '';
111
-		$this->dateTime = new \DateTime();
112
-		$this->dateTime->setTimestamp(0);
113
-		$this->objectType = '';
114
-		$this->objectId = '';
115
-		$this->subject = '';
116
-		$this->subjectParameters = [];
117
-		$this->subjectParsed = '';
118
-		$this->subjectRich = '';
119
-		$this->subjectRichParameters = [];
120
-		$this->message = '';
121
-		$this->messageParameters = [];
122
-		$this->messageParsed = '';
123
-		$this->messageRich = '';
124
-		$this->messageRichParameters = [];
125
-		$this->link = '';
126
-		$this->icon = '';
127
-		$this->actions = [];
128
-		$this->actionsParsed = [];
129
-	}
130
-
131
-	/**
132
-	 * @param string $app
133
-	 * @return $this
134
-	 * @throws \InvalidArgumentException if the app id is invalid
135
-	 * @since 8.2.0
136
-	 */
137
-	public function setApp(string $app) {
138
-		if (trim($app) === '' || isset($app[32])) {
139
-			throw new \InvalidArgumentException('The given app name is invalid');
140
-		}
141
-		$this->app = $app;
142
-		return $this;
143
-	}
144
-
145
-	/**
146
-	 * @return string
147
-	 * @since 8.2.0
148
-	 */
149
-	public function getApp() {
150
-		return $this->app;
151
-	}
152
-
153
-	/**
154
-	 * @param string $user
155
-	 * @return $this
156
-	 * @throws \InvalidArgumentException if the user id is invalid
157
-	 * @since 8.2.0
158
-	 */
159
-	public function setUser(string $user) {
160
-		if (trim($user) === '' || isset($user[64])) {
161
-			throw new \InvalidArgumentException('The given user id is invalid');
162
-		}
163
-		$this->user = $user;
164
-		return $this;
165
-	}
166
-
167
-	/**
168
-	 * @return string
169
-	 * @since 8.2.0
170
-	 */
171
-	public function getUser() {
172
-		return $this->user;
173
-	}
174
-
175
-	/**
176
-	 * @param \DateTime $dateTime
177
-	 * @return $this
178
-	 * @throws \InvalidArgumentException if the $dateTime is invalid
179
-	 * @since 9.0.0
180
-	 */
181
-	public function setDateTime(\DateTime $dateTime) {
182
-		if ($dateTime->getTimestamp() === 0) {
183
-			throw new \InvalidArgumentException('The given date time is invalid');
184
-		}
185
-		$this->dateTime = $dateTime;
186
-		return $this;
187
-	}
188
-
189
-	/**
190
-	 * @return \DateTime
191
-	 * @since 9.0.0
192
-	 */
193
-	public function getDateTime() {
194
-		return $this->dateTime;
195
-	}
196
-
197
-	/**
198
-	 * @param string $type
199
-	 * @param string $id
200
-	 * @return $this
201
-	 * @throws \InvalidArgumentException if the object type or id is invalid
202
-	 * @since 8.2.0 - 9.0.0: Type of $id changed to string
203
-	 */
204
-	public function setObject(string $type, $id) {
205
-		if (trim($type) === '' || isset($type[64])) {
206
-			throw new \InvalidArgumentException('The given object type is invalid');
207
-		}
208
-		$this->objectType = $type;
209
-
210
-		if (!is_int($id) && (!is_string($id) || $id === '' || isset($id[64]))) {
211
-			throw new \InvalidArgumentException('The given object id is invalid');
212
-		}
213
-		$this->objectId = (string) $id;
214
-		return $this;
215
-	}
216
-
217
-	/**
218
-	 * @return string
219
-	 * @since 8.2.0
220
-	 */
221
-	public function getObjectType() {
222
-		return $this->objectType;
223
-	}
224
-
225
-	/**
226
-	 * @return string
227
-	 * @since 8.2.0 - 9.0.0: Return type changed to string
228
-	 */
229
-	public function getObjectId() {
230
-		return $this->objectId;
231
-	}
232
-
233
-	/**
234
-	 * @param string $subject
235
-	 * @param array $parameters
236
-	 * @return $this
237
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
238
-	 * @since 8.2.0
239
-	 */
240
-	public function setSubject(string $subject, array $parameters = []) {
241
-		if (trim($subject) === '' || isset($subject[64])) {
242
-			throw new \InvalidArgumentException('The given subject is invalid');
243
-		}
244
-
245
-		$this->subject = $subject;
246
-		$this->subjectParameters = $parameters;
247
-
248
-		return $this;
249
-	}
250
-
251
-	/**
252
-	 * @return string
253
-	 * @since 8.2.0
254
-	 */
255
-	public function getSubject() {
256
-		return $this->subject;
257
-	}
258
-
259
-	/**
260
-	 * @return string[]
261
-	 * @since 8.2.0
262
-	 */
263
-	public function getSubjectParameters() {
264
-		return $this->subjectParameters;
265
-	}
266
-
267
-	/**
268
-	 * @param string $subject
269
-	 * @return $this
270
-	 * @throws \InvalidArgumentException if the subject is invalid
271
-	 * @since 8.2.0
272
-	 */
273
-	public function setParsedSubject(string $subject) {
274
-		if (trim($subject) === '') {
275
-			throw new \InvalidArgumentException('The given parsed subject is invalid');
276
-		}
277
-		$this->subjectParsed = $subject;
278
-		return $this;
279
-	}
280
-
281
-	/**
282
-	 * @return string
283
-	 * @since 8.2.0
284
-	 */
285
-	public function getParsedSubject() {
286
-		return $this->subjectParsed;
287
-	}
288
-
289
-	/**
290
-	 * @param string $subject
291
-	 * @param array $parameters
292
-	 * @return $this
293
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
294
-	 * @since 11.0.0
295
-	 */
296
-	public function setRichSubject(string $subject, array $parameters = []) {
297
-		if (trim($subject) === '') {
298
-			throw new \InvalidArgumentException('The given parsed subject is invalid');
299
-		}
300
-
301
-		$this->subjectRich = $subject;
302
-		$this->subjectRichParameters = $parameters;
303
-
304
-		return $this;
305
-	}
306
-
307
-	/**
308
-	 * @return string
309
-	 * @since 11.0.0
310
-	 */
311
-	public function getRichSubject() {
312
-		return $this->subjectRich;
313
-	}
314
-
315
-	/**
316
-	 * @return array[]
317
-	 * @since 11.0.0
318
-	 */
319
-	public function getRichSubjectParameters() {
320
-		return $this->subjectRichParameters;
321
-	}
322
-
323
-	/**
324
-	 * @param string $message
325
-	 * @param array $parameters
326
-	 * @return $this
327
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
328
-	 * @since 8.2.0
329
-	 */
330
-	public function setMessage(string $message, array $parameters = []) {
331
-		if (trim($message) === '' || isset($message[64])) {
332
-			throw new \InvalidArgumentException('The given message is invalid');
333
-		}
334
-
335
-		$this->message = $message;
336
-		$this->messageParameters = $parameters;
337
-
338
-		return $this;
339
-	}
340
-
341
-	/**
342
-	 * @return string
343
-	 * @since 8.2.0
344
-	 */
345
-	public function getMessage() {
346
-		return $this->message;
347
-	}
348
-
349
-	/**
350
-	 * @return string[]
351
-	 * @since 8.2.0
352
-	 */
353
-	public function getMessageParameters() {
354
-		return $this->messageParameters;
355
-	}
356
-
357
-	/**
358
-	 * @param string $message
359
-	 * @return $this
360
-	 * @throws \InvalidArgumentException if the message is invalid
361
-	 * @since 8.2.0
362
-	 */
363
-	public function setParsedMessage(string $message) {
364
-		if (trim($message) === '') {
365
-			throw new \InvalidArgumentException('The given parsed message is invalid');
366
-		}
367
-		$this->messageParsed = $message;
368
-		return $this;
369
-	}
370
-
371
-	/**
372
-	 * @return string
373
-	 * @since 8.2.0
374
-	 */
375
-	public function getParsedMessage() {
376
-		return $this->messageParsed;
377
-	}
378
-
379
-	/**
380
-	 * @param string $message
381
-	 * @param array $parameters
382
-	 * @return $this
383
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
384
-	 * @since 11.0.0
385
-	 */
386
-	public function setRichMessage(string $message, array $parameters = []) {
387
-		if (trim($message) === '') {
388
-			throw new \InvalidArgumentException('The given parsed message is invalid');
389
-		}
390
-
391
-		$this->messageRich = $message;
392
-		$this->messageRichParameters = $parameters;
393
-
394
-		return $this;
395
-	}
396
-
397
-	/**
398
-	 * @return string
399
-	 * @since 11.0.0
400
-	 */
401
-	public function getRichMessage() {
402
-		return $this->messageRich;
403
-	}
404
-
405
-	/**
406
-	 * @return array[]
407
-	 * @since 11.0.0
408
-	 */
409
-	public function getRichMessageParameters() {
410
-		return $this->messageRichParameters;
411
-	}
412
-
413
-	/**
414
-	 * @param string $link
415
-	 * @return $this
416
-	 * @throws \InvalidArgumentException if the link is invalid
417
-	 * @since 8.2.0
418
-	 */
419
-	public function setLink(string $link) {
420
-		if (trim($link) === '' || isset($link[4000])) {
421
-			throw new \InvalidArgumentException('The given link is invalid');
422
-		}
423
-		$this->link = $link;
424
-		return $this;
425
-	}
426
-
427
-	/**
428
-	 * @return string
429
-	 * @since 8.2.0
430
-	 */
431
-	public function getLink() {
432
-		return $this->link;
433
-	}
434
-
435
-	/**
436
-	 * @param string $icon
437
-	 * @return $this
438
-	 * @throws \InvalidArgumentException if the icon is invalid
439
-	 * @since 11.0.0
440
-	 */
441
-	public function setIcon(string $icon) {
442
-		if (trim($icon) === '' || isset($icon[4000])) {
443
-			throw new \InvalidArgumentException('The given icon is invalid');
444
-		}
445
-		$this->icon = $icon;
446
-		return $this;
447
-	}
448
-
449
-	/**
450
-	 * @return string
451
-	 * @since 11.0.0
452
-	 */
453
-	public function getIcon() {
454
-		return $this->icon;
455
-	}
456
-
457
-	/**
458
-	 * @return IAction
459
-	 * @since 8.2.0
460
-	 */
461
-	public function createAction() {
462
-		return new Action();
463
-	}
464
-
465
-	/**
466
-	 * @param IAction $action
467
-	 * @return $this
468
-	 * @throws \InvalidArgumentException if the action is invalid
469
-	 * @since 8.2.0
470
-	 */
471
-	public function addAction(IAction $action) {
472
-		if (!$action->isValid()) {
473
-			throw new \InvalidArgumentException('The given action is invalid');
474
-		}
475
-
476
-		if ($action->isPrimary()) {
477
-			if ($this->hasPrimaryAction) {
478
-				throw new \InvalidArgumentException('The notification already has a primary action');
479
-			}
480
-
481
-			$this->hasPrimaryAction = true;
482
-		}
483
-
484
-		$this->actions[] = $action;
485
-		return $this;
486
-	}
487
-
488
-	/**
489
-	 * @return IAction[]
490
-	 * @since 8.2.0
491
-	 */
492
-	public function getActions() {
493
-		return $this->actions;
494
-	}
495
-
496
-	/**
497
-	 * @param IAction $action
498
-	 * @return $this
499
-	 * @throws \InvalidArgumentException if the action is invalid
500
-	 * @since 8.2.0
501
-	 */
502
-	public function addParsedAction(IAction $action) {
503
-		if (!$action->isValidParsed()) {
504
-			throw new \InvalidArgumentException('The given parsed action is invalid');
505
-		}
506
-
507
-		if ($action->isPrimary()) {
508
-			if ($this->hasPrimaryParsedAction) {
509
-				throw new \InvalidArgumentException('The notification already has a primary action');
510
-			}
511
-
512
-			$this->hasPrimaryParsedAction = true;
513
-
514
-			// Make sure the primary action is always the first one
515
-			array_unshift($this->actionsParsed, $action);
516
-		} else {
517
-			$this->actionsParsed[] = $action;
518
-		}
519
-
520
-		return $this;
521
-	}
522
-
523
-	/**
524
-	 * @return IAction[]
525
-	 * @since 8.2.0
526
-	 */
527
-	public function getParsedActions() {
528
-		return $this->actionsParsed;
529
-	}
530
-
531
-	/**
532
-	 * @return bool
533
-	 * @since 8.2.0
534
-	 */
535
-	public function isValid() {
536
-		return
537
-			$this->isValidCommon()
538
-			&&
539
-			$this->getSubject() !== ''
540
-		;
541
-	}
542
-
543
-	/**
544
-	 * @return bool
545
-	 * @since 8.2.0
546
-	 */
547
-	public function isValidParsed() {
548
-		if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
549
-			try {
550
-				$this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
551
-			} catch (InvalidObjectExeption $e) {
552
-				return false;
553
-			}
554
-		}
555
-
556
-		if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
557
-			try {
558
-				$this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
559
-			} catch (InvalidObjectExeption $e) {
560
-				return false;
561
-			}
562
-		}
563
-
564
-		return
565
-			$this->isValidCommon()
566
-			&&
567
-			$this->getParsedSubject() !== ''
568
-		;
569
-	}
570
-
571
-	/**
572
-	 * @return bool
573
-	 */
574
-	protected function isValidCommon() {
575
-		return
576
-			$this->getApp() !== ''
577
-			&&
578
-			$this->getUser() !== ''
579
-			&&
580
-			$this->getDateTime()->getTimestamp() !== 0
581
-			&&
582
-			$this->getObjectType() !== ''
583
-			&&
584
-			$this->getObjectId() !== ''
585
-		;
586
-	}
36
+    /** @var IValidator */
37
+    protected $richValidator;
38
+
39
+    /** @var string */
40
+    protected $app;
41
+
42
+    /** @var string */
43
+    protected $user;
44
+
45
+    /** @var \DateTime */
46
+    protected $dateTime;
47
+
48
+    /** @var string */
49
+    protected $objectType;
50
+
51
+    /** @var string */
52
+    protected $objectId;
53
+
54
+    /** @var string */
55
+    protected $subject;
56
+
57
+    /** @var array */
58
+    protected $subjectParameters;
59
+
60
+    /** @var string */
61
+    protected $subjectParsed;
62
+
63
+    /** @var string */
64
+    protected $subjectRich;
65
+
66
+    /** @var array */
67
+    protected $subjectRichParameters;
68
+
69
+    /** @var string */
70
+    protected $message;
71
+
72
+    /** @var array */
73
+    protected $messageParameters;
74
+
75
+    /** @var string */
76
+    protected $messageParsed;
77
+
78
+    /** @var string */
79
+    protected $messageRich;
80
+
81
+    /** @var array */
82
+    protected $messageRichParameters;
83
+
84
+    /** @var string */
85
+    protected $link;
86
+
87
+    /** @var string */
88
+    protected $icon;
89
+
90
+    /** @var array */
91
+    protected $actions;
92
+
93
+    /** @var array */
94
+    protected $actionsParsed;
95
+
96
+    /** @var bool */
97
+    protected $hasPrimaryAction;
98
+
99
+    /** @var bool */
100
+    protected $hasPrimaryParsedAction;
101
+
102
+    /**
103
+     * Constructor
104
+     *
105
+     * @param IValidator $richValidator
106
+     */
107
+    public function __construct(IValidator $richValidator) {
108
+        $this->richValidator = $richValidator;
109
+        $this->app = '';
110
+        $this->user = '';
111
+        $this->dateTime = new \DateTime();
112
+        $this->dateTime->setTimestamp(0);
113
+        $this->objectType = '';
114
+        $this->objectId = '';
115
+        $this->subject = '';
116
+        $this->subjectParameters = [];
117
+        $this->subjectParsed = '';
118
+        $this->subjectRich = '';
119
+        $this->subjectRichParameters = [];
120
+        $this->message = '';
121
+        $this->messageParameters = [];
122
+        $this->messageParsed = '';
123
+        $this->messageRich = '';
124
+        $this->messageRichParameters = [];
125
+        $this->link = '';
126
+        $this->icon = '';
127
+        $this->actions = [];
128
+        $this->actionsParsed = [];
129
+    }
130
+
131
+    /**
132
+     * @param string $app
133
+     * @return $this
134
+     * @throws \InvalidArgumentException if the app id is invalid
135
+     * @since 8.2.0
136
+     */
137
+    public function setApp(string $app) {
138
+        if (trim($app) === '' || isset($app[32])) {
139
+            throw new \InvalidArgumentException('The given app name is invalid');
140
+        }
141
+        $this->app = $app;
142
+        return $this;
143
+    }
144
+
145
+    /**
146
+     * @return string
147
+     * @since 8.2.0
148
+     */
149
+    public function getApp() {
150
+        return $this->app;
151
+    }
152
+
153
+    /**
154
+     * @param string $user
155
+     * @return $this
156
+     * @throws \InvalidArgumentException if the user id is invalid
157
+     * @since 8.2.0
158
+     */
159
+    public function setUser(string $user) {
160
+        if (trim($user) === '' || isset($user[64])) {
161
+            throw new \InvalidArgumentException('The given user id is invalid');
162
+        }
163
+        $this->user = $user;
164
+        return $this;
165
+    }
166
+
167
+    /**
168
+     * @return string
169
+     * @since 8.2.0
170
+     */
171
+    public function getUser() {
172
+        return $this->user;
173
+    }
174
+
175
+    /**
176
+     * @param \DateTime $dateTime
177
+     * @return $this
178
+     * @throws \InvalidArgumentException if the $dateTime is invalid
179
+     * @since 9.0.0
180
+     */
181
+    public function setDateTime(\DateTime $dateTime) {
182
+        if ($dateTime->getTimestamp() === 0) {
183
+            throw new \InvalidArgumentException('The given date time is invalid');
184
+        }
185
+        $this->dateTime = $dateTime;
186
+        return $this;
187
+    }
188
+
189
+    /**
190
+     * @return \DateTime
191
+     * @since 9.0.0
192
+     */
193
+    public function getDateTime() {
194
+        return $this->dateTime;
195
+    }
196
+
197
+    /**
198
+     * @param string $type
199
+     * @param string $id
200
+     * @return $this
201
+     * @throws \InvalidArgumentException if the object type or id is invalid
202
+     * @since 8.2.0 - 9.0.0: Type of $id changed to string
203
+     */
204
+    public function setObject(string $type, $id) {
205
+        if (trim($type) === '' || isset($type[64])) {
206
+            throw new \InvalidArgumentException('The given object type is invalid');
207
+        }
208
+        $this->objectType = $type;
209
+
210
+        if (!is_int($id) && (!is_string($id) || $id === '' || isset($id[64]))) {
211
+            throw new \InvalidArgumentException('The given object id is invalid');
212
+        }
213
+        $this->objectId = (string) $id;
214
+        return $this;
215
+    }
216
+
217
+    /**
218
+     * @return string
219
+     * @since 8.2.0
220
+     */
221
+    public function getObjectType() {
222
+        return $this->objectType;
223
+    }
224
+
225
+    /**
226
+     * @return string
227
+     * @since 8.2.0 - 9.0.0: Return type changed to string
228
+     */
229
+    public function getObjectId() {
230
+        return $this->objectId;
231
+    }
232
+
233
+    /**
234
+     * @param string $subject
235
+     * @param array $parameters
236
+     * @return $this
237
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
238
+     * @since 8.2.0
239
+     */
240
+    public function setSubject(string $subject, array $parameters = []) {
241
+        if (trim($subject) === '' || isset($subject[64])) {
242
+            throw new \InvalidArgumentException('The given subject is invalid');
243
+        }
244
+
245
+        $this->subject = $subject;
246
+        $this->subjectParameters = $parameters;
247
+
248
+        return $this;
249
+    }
250
+
251
+    /**
252
+     * @return string
253
+     * @since 8.2.0
254
+     */
255
+    public function getSubject() {
256
+        return $this->subject;
257
+    }
258
+
259
+    /**
260
+     * @return string[]
261
+     * @since 8.2.0
262
+     */
263
+    public function getSubjectParameters() {
264
+        return $this->subjectParameters;
265
+    }
266
+
267
+    /**
268
+     * @param string $subject
269
+     * @return $this
270
+     * @throws \InvalidArgumentException if the subject is invalid
271
+     * @since 8.2.0
272
+     */
273
+    public function setParsedSubject(string $subject) {
274
+        if (trim($subject) === '') {
275
+            throw new \InvalidArgumentException('The given parsed subject is invalid');
276
+        }
277
+        $this->subjectParsed = $subject;
278
+        return $this;
279
+    }
280
+
281
+    /**
282
+     * @return string
283
+     * @since 8.2.0
284
+     */
285
+    public function getParsedSubject() {
286
+        return $this->subjectParsed;
287
+    }
288
+
289
+    /**
290
+     * @param string $subject
291
+     * @param array $parameters
292
+     * @return $this
293
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
294
+     * @since 11.0.0
295
+     */
296
+    public function setRichSubject(string $subject, array $parameters = []) {
297
+        if (trim($subject) === '') {
298
+            throw new \InvalidArgumentException('The given parsed subject is invalid');
299
+        }
300
+
301
+        $this->subjectRich = $subject;
302
+        $this->subjectRichParameters = $parameters;
303
+
304
+        return $this;
305
+    }
306
+
307
+    /**
308
+     * @return string
309
+     * @since 11.0.0
310
+     */
311
+    public function getRichSubject() {
312
+        return $this->subjectRich;
313
+    }
314
+
315
+    /**
316
+     * @return array[]
317
+     * @since 11.0.0
318
+     */
319
+    public function getRichSubjectParameters() {
320
+        return $this->subjectRichParameters;
321
+    }
322
+
323
+    /**
324
+     * @param string $message
325
+     * @param array $parameters
326
+     * @return $this
327
+     * @throws \InvalidArgumentException if the message or parameters are invalid
328
+     * @since 8.2.0
329
+     */
330
+    public function setMessage(string $message, array $parameters = []) {
331
+        if (trim($message) === '' || isset($message[64])) {
332
+            throw new \InvalidArgumentException('The given message is invalid');
333
+        }
334
+
335
+        $this->message = $message;
336
+        $this->messageParameters = $parameters;
337
+
338
+        return $this;
339
+    }
340
+
341
+    /**
342
+     * @return string
343
+     * @since 8.2.0
344
+     */
345
+    public function getMessage() {
346
+        return $this->message;
347
+    }
348
+
349
+    /**
350
+     * @return string[]
351
+     * @since 8.2.0
352
+     */
353
+    public function getMessageParameters() {
354
+        return $this->messageParameters;
355
+    }
356
+
357
+    /**
358
+     * @param string $message
359
+     * @return $this
360
+     * @throws \InvalidArgumentException if the message is invalid
361
+     * @since 8.2.0
362
+     */
363
+    public function setParsedMessage(string $message) {
364
+        if (trim($message) === '') {
365
+            throw new \InvalidArgumentException('The given parsed message is invalid');
366
+        }
367
+        $this->messageParsed = $message;
368
+        return $this;
369
+    }
370
+
371
+    /**
372
+     * @return string
373
+     * @since 8.2.0
374
+     */
375
+    public function getParsedMessage() {
376
+        return $this->messageParsed;
377
+    }
378
+
379
+    /**
380
+     * @param string $message
381
+     * @param array $parameters
382
+     * @return $this
383
+     * @throws \InvalidArgumentException if the message or parameters are invalid
384
+     * @since 11.0.0
385
+     */
386
+    public function setRichMessage(string $message, array $parameters = []) {
387
+        if (trim($message) === '') {
388
+            throw new \InvalidArgumentException('The given parsed message is invalid');
389
+        }
390
+
391
+        $this->messageRich = $message;
392
+        $this->messageRichParameters = $parameters;
393
+
394
+        return $this;
395
+    }
396
+
397
+    /**
398
+     * @return string
399
+     * @since 11.0.0
400
+     */
401
+    public function getRichMessage() {
402
+        return $this->messageRich;
403
+    }
404
+
405
+    /**
406
+     * @return array[]
407
+     * @since 11.0.0
408
+     */
409
+    public function getRichMessageParameters() {
410
+        return $this->messageRichParameters;
411
+    }
412
+
413
+    /**
414
+     * @param string $link
415
+     * @return $this
416
+     * @throws \InvalidArgumentException if the link is invalid
417
+     * @since 8.2.0
418
+     */
419
+    public function setLink(string $link) {
420
+        if (trim($link) === '' || isset($link[4000])) {
421
+            throw new \InvalidArgumentException('The given link is invalid');
422
+        }
423
+        $this->link = $link;
424
+        return $this;
425
+    }
426
+
427
+    /**
428
+     * @return string
429
+     * @since 8.2.0
430
+     */
431
+    public function getLink() {
432
+        return $this->link;
433
+    }
434
+
435
+    /**
436
+     * @param string $icon
437
+     * @return $this
438
+     * @throws \InvalidArgumentException if the icon is invalid
439
+     * @since 11.0.0
440
+     */
441
+    public function setIcon(string $icon) {
442
+        if (trim($icon) === '' || isset($icon[4000])) {
443
+            throw new \InvalidArgumentException('The given icon is invalid');
444
+        }
445
+        $this->icon = $icon;
446
+        return $this;
447
+    }
448
+
449
+    /**
450
+     * @return string
451
+     * @since 11.0.0
452
+     */
453
+    public function getIcon() {
454
+        return $this->icon;
455
+    }
456
+
457
+    /**
458
+     * @return IAction
459
+     * @since 8.2.0
460
+     */
461
+    public function createAction() {
462
+        return new Action();
463
+    }
464
+
465
+    /**
466
+     * @param IAction $action
467
+     * @return $this
468
+     * @throws \InvalidArgumentException if the action is invalid
469
+     * @since 8.2.0
470
+     */
471
+    public function addAction(IAction $action) {
472
+        if (!$action->isValid()) {
473
+            throw new \InvalidArgumentException('The given action is invalid');
474
+        }
475
+
476
+        if ($action->isPrimary()) {
477
+            if ($this->hasPrimaryAction) {
478
+                throw new \InvalidArgumentException('The notification already has a primary action');
479
+            }
480
+
481
+            $this->hasPrimaryAction = true;
482
+        }
483
+
484
+        $this->actions[] = $action;
485
+        return $this;
486
+    }
487
+
488
+    /**
489
+     * @return IAction[]
490
+     * @since 8.2.0
491
+     */
492
+    public function getActions() {
493
+        return $this->actions;
494
+    }
495
+
496
+    /**
497
+     * @param IAction $action
498
+     * @return $this
499
+     * @throws \InvalidArgumentException if the action is invalid
500
+     * @since 8.2.0
501
+     */
502
+    public function addParsedAction(IAction $action) {
503
+        if (!$action->isValidParsed()) {
504
+            throw new \InvalidArgumentException('The given parsed action is invalid');
505
+        }
506
+
507
+        if ($action->isPrimary()) {
508
+            if ($this->hasPrimaryParsedAction) {
509
+                throw new \InvalidArgumentException('The notification already has a primary action');
510
+            }
511
+
512
+            $this->hasPrimaryParsedAction = true;
513
+
514
+            // Make sure the primary action is always the first one
515
+            array_unshift($this->actionsParsed, $action);
516
+        } else {
517
+            $this->actionsParsed[] = $action;
518
+        }
519
+
520
+        return $this;
521
+    }
522
+
523
+    /**
524
+     * @return IAction[]
525
+     * @since 8.2.0
526
+     */
527
+    public function getParsedActions() {
528
+        return $this->actionsParsed;
529
+    }
530
+
531
+    /**
532
+     * @return bool
533
+     * @since 8.2.0
534
+     */
535
+    public function isValid() {
536
+        return
537
+            $this->isValidCommon()
538
+            &&
539
+            $this->getSubject() !== ''
540
+        ;
541
+    }
542
+
543
+    /**
544
+     * @return bool
545
+     * @since 8.2.0
546
+     */
547
+    public function isValidParsed() {
548
+        if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
549
+            try {
550
+                $this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
551
+            } catch (InvalidObjectExeption $e) {
552
+                return false;
553
+            }
554
+        }
555
+
556
+        if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
557
+            try {
558
+                $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
559
+            } catch (InvalidObjectExeption $e) {
560
+                return false;
561
+            }
562
+        }
563
+
564
+        return
565
+            $this->isValidCommon()
566
+            &&
567
+            $this->getParsedSubject() !== ''
568
+        ;
569
+    }
570
+
571
+    /**
572
+     * @return bool
573
+     */
574
+    protected function isValidCommon() {
575
+        return
576
+            $this->getApp() !== ''
577
+            &&
578
+            $this->getUser() !== ''
579
+            &&
580
+            $this->getDateTime()->getTimestamp() !== 0
581
+            &&
582
+            $this->getObjectType() !== ''
583
+            &&
584
+            $this->getObjectId() !== ''
585
+        ;
586
+    }
587 587
 }
Please login to merge, or discard this patch.