Code Duplication    Length = 7-10 lines in 15 locations

lib/private/Notification/Action.php 1 location

@@ 65-71 (lines=7) @@
62
	 * @throws \InvalidArgumentException if the label is invalid
63
	 * @since 8.2.0
64
	 */
65
	public function setLabel($label) {
66
		if (!is_string($label) || $label === '' || isset($label[32])) {
67
			throw new \InvalidArgumentException('The given label is invalid');
68
		}
69
		$this->label = $label;
70
		return $this;
71
	}
72
73
	/**
74
	 * @return string

lib/private/Notification/Notification.php 6 locations

@@ 135-141 (lines=7) @@
132
	 * @throws \InvalidArgumentException if the app id is invalid
133
	 * @since 8.2.0
134
	 */
135
	public function setApp($app) {
136
		if (!is_string($app) || $app === '' || isset($app[32])) {
137
			throw new \InvalidArgumentException('The given app name is invalid');
138
		}
139
		$this->app = $app;
140
		return $this;
141
	}
142
143
	/**
144
	 * @return string
@@ 157-163 (lines=7) @@
154
	 * @throws \InvalidArgumentException if the user id is invalid
155
	 * @since 8.2.0
156
	 */
157
	public function setUser($user) {
158
		if (!is_string($user) || $user === '' || isset($user[64])) {
159
			throw new \InvalidArgumentException('The given user id is invalid');
160
		}
161
		$this->user = $user;
162
		return $this;
163
	}
164
165
	/**
166
	 * @return string
@@ 238-247 (lines=10) @@
235
	 * @throws \InvalidArgumentException if the subject or parameters are invalid
236
	 * @since 8.2.0
237
	 */
238
	public function setSubject($subject, array $parameters = []) {
239
		if (!is_string($subject) || $subject === '' || isset($subject[64])) {
240
			throw new \InvalidArgumentException('The given subject is invalid');
241
		}
242
243
		$this->subject = $subject;
244
		$this->subjectParameters = $parameters;
245
246
		return $this;
247
	}
248
249
	/**
250
	 * @return string
@@ 328-337 (lines=10) @@
325
	 * @throws \InvalidArgumentException if the message or parameters are invalid
326
	 * @since 8.2.0
327
	 */
328
	public function setMessage($message, array $parameters = []) {
329
		if (!is_string($message) || $message === '' || isset($message[64])) {
330
			throw new \InvalidArgumentException('The given message is invalid');
331
		}
332
333
		$this->message = $message;
334
		$this->messageParameters = $parameters;
335
336
		return $this;
337
	}
338
339
	/**
340
	 * @return string
@@ 417-423 (lines=7) @@
414
	 * @throws \InvalidArgumentException if the link is invalid
415
	 * @since 8.2.0
416
	 */
417
	public function setLink($link) {
418
		if (!is_string($link) || $link === '' || isset($link[4000])) {
419
			throw new \InvalidArgumentException('The given link is invalid');
420
		}
421
		$this->link = $link;
422
		return $this;
423
	}
424
425
	/**
426
	 * @return string
@@ 439-445 (lines=7) @@
436
	 * @throws \InvalidArgumentException if the icon is invalid
437
	 * @since 11.0.0
438
	 */
439
	public function setIcon($icon) {
440
		if (!is_string($icon) || $icon === '' || isset($icon[4000])) {
441
			throw new \InvalidArgumentException('The given icon is invalid');
442
		}
443
		$this->icon = $icon;
444
		return $this;
445
	}
446
447
	/**
448
	 * @return string

lib/private/Activity/Event.php 8 locations

@@ 93-99 (lines=7) @@
90
	 * @throws \InvalidArgumentException if the app id is invalid
91
	 * @since 8.2.0
92
	 */
93
	public function setApp($app) {
94
		if (!is_string($app) || $app === '' || isset($app[32])) {
95
			throw new \InvalidArgumentException('The given app is invalid');
96
		}
97
		$this->app = (string) $app;
98
		return $this;
99
	}
100
101
	/**
102
	 * @return string
@@ 116-122 (lines=7) @@
113
	 * @throws \InvalidArgumentException if the type is invalid
114
	 * @since 8.2.0
115
	 */
116
	public function setType($type) {
117
		if (!is_string($type) || $type === '' || isset($type[255])) {
118
			throw new \InvalidArgumentException('The given type is invalid');
119
		}
120
		$this->type = (string) $type;
121
		return $this;
122
	}
123
124
	/**
125
	 * @return string
@@ 139-145 (lines=7) @@
136
	 * @throws \InvalidArgumentException if the affected user is invalid
137
	 * @since 8.2.0
138
	 */
139
	public function setAffectedUser($affectedUser) {
140
		if (!is_string($affectedUser) || $affectedUser === '' || isset($affectedUser[64])) {
141
			throw new \InvalidArgumentException('The given affected user is invalid');
142
		}
143
		$this->affectedUser = (string) $affectedUser;
144
		return $this;
145
	}
146
147
	/**
148
	 * @return string
@@ 162-168 (lines=7) @@
159
	 * @throws \InvalidArgumentException if the author is invalid
160
	 * @since 8.2.0
161
	 */
162
	public function setAuthor($author) {
163
		if (!is_string($author) || isset($author[64])) {
164
			throw new \InvalidArgumentException('The given author user is invalid'. serialize($author));
165
		}
166
		$this->author = (string) $author;
167
		return $this;
168
	}
169
170
	/**
171
	 * @return string
@@ 209-216 (lines=8) @@
206
	 * @throws \InvalidArgumentException if the subject or parameters are invalid
207
	 * @since 8.2.0
208
	 */
209
	public function setSubject($subject, array $parameters = []) {
210
		if (!is_string($subject) || isset($subject[255])) {
211
			throw new \InvalidArgumentException('The given subject is invalid');
212
		}
213
		$this->subject = (string) $subject;
214
		$this->subjectParameters = $parameters;
215
		return $this;
216
	}
217
218
	/**
219
	 * @return string
@@ 300-307 (lines=8) @@
297
	 * @throws \InvalidArgumentException if the message or parameters are invalid
298
	 * @since 8.2.0
299
	 */
300
	public function setMessage($message, array $parameters = []) {
301
		if (!is_string($message) || isset($message[255])) {
302
			throw new \InvalidArgumentException('The given message is invalid');
303
		}
304
		$this->message = (string) $message;
305
		$this->messageParameters = $parameters;
306
		return $this;
307
	}
308
309
	/**
310
	 * @return string
@@ 437-443 (lines=7) @@
434
	 * @throws \InvalidArgumentException if the link is invalid
435
	 * @since 8.2.0
436
	 */
437
	public function setLink($link) {
438
		if (!is_string($link) || isset($link[4000])) {
439
			throw new \InvalidArgumentException('The given link is invalid');
440
		}
441
		$this->link = (string) $link;
442
		return $this;
443
	}
444
445
	/**
446
	 * @return string
@@ 458-464 (lines=7) @@
455
	 * @throws \InvalidArgumentException if the icon is invalid
456
	 * @since 11.0.0
457
	 */
458
	public function setIcon($icon) {
459
		if (!is_string($icon) || isset($icon[4000])) {
460
			throw new \InvalidArgumentException('The given icon is invalid');
461
		}
462
		$this->icon = $icon;
463
		return $this;
464
	}
465
466
	/**
467
	 * @return string