Completed
Push — master ( 4a1ba1...57797d )
by Maxence
02:13
created

SubjectProvider::parseMemberInvited()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 14
loc 14
rs 9.4285
cc 2
eloc 9
nc 2
nop 3
1
<?php
2
/**
3
 * Circles - Bring cloud-users closer together.
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Maxence Lange <[email protected]>
9
 * @copyright 2017
10
 * @license GNU AGPL version 3 or any later version
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License as
14
 * published by the Free Software Foundation, either version 3 of the
15
 * License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Affero General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License
23
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 *
25
 */
26
27
28
namespace OCA\Circles\Activity;
29
30
31
use OCA\Circles\Exceptions\FakeException;
32
use OCA\Circles\Model\Circle;
33
use OCA\Circles\Model\FederatedLink;
34
use OCA\Circles\Model\Member;
35
use OCP\Activity\IEvent;
36
37
class SubjectProvider extends BaseProvider {
38
39
	/**
40
	 * Parse on Subject 'member_join'.
41
	 * If circle is closed, we say that user accepted his invitation.
42
	 *
43
	 * @param IEvent $event
44
	 * @param Circle $circle
45
	 * @param Member $member
46
	 *
47
	 * @throws FakeException
48
	 */
49
	public function parseSubjectMemberJoin(IEvent &$event, Circle $circle, Member $member) {
50
		if ($event->getSubject() !== 'member_request_invitation') {
51
			return;
52
		}
53
54
		$this->parseSubjectMemberJoinClosedCircle($event, $circle, $member);
55
		$this->parseCircleMemberEvent(
56
			$event, $circle, $member, $this->l10n->t('You joined {circle}'),
57
			$this->l10n->t('{member} joined {circle}')
58
		);
59
60
		throw new FakeException();
61
	}
62
63
64
	/**
65
	 * @param IEvent $event
66
	 * @param Circle $circle
67
	 * @param Member $member
68
	 *
69
	 * @throws FakeException
70
	 */
71
	public function parseSubjectMemberJoinClosedCircle(IEvent &$event, Circle $circle, Member $member) {
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 101 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
72
		if ($circle->getType() !== Circle::CIRCLES_CLOSED) {
73
			return;
74
		}
75
76
		$this->parseCircleMemberEvent(
77
			$event, $circle, $member,
78
			$this->l10n->t('You accepted the invitation to join {circle}'),
79
			$this->l10n->t('{member} accepted the invitation to join {circle}')
80
		);
81
82
		throw new FakeException();
83
	}
84
85
86
	/**
87
	 * Parse on Subject 'member_add'.
88
	 * If circle is closed, we say that user's invitation was accepted.
89
	 *
90
	 * @param IEvent $event
91
	 * @param Circle $circle
92
	 * @param Member $member
93
	 *
94
	 * @throws FakeException
95
	 */
96 View Code Duplication
	public function parseSubjectMemberAdd(IEvent &$event, Circle $circle, Member $member) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
97
		if ($event->getSubject() !== 'member_add') {
98
			return;
99
		}
100
101
		$this->parseSubjectMemberAddClosedCircle($event, $circle, $member);
102
		$this->parseCircleMemberAdvancedEvent(
103
			$event, $circle, $member,
104
			$this->l10n->t('You added {member} as member to {circle}'),
105
			$this->l10n->t('You have been added as member to {circle} by {author}'),
106
			$this->l10n->t('{member} has been added as member to {circle} by {author}')
107
		);
108
109
		throw new FakeException();
110
	}
111
112
113
	/**
114
	 * @param IEvent $event
115
	 * @param Circle $circle
116
	 * @param Member $member
117
	 *
118
	 * @throws FakeException
119
	 */
120
	public function parseSubjectMemberAddClosedCircle(IEvent &$event, Circle $circle, Member $member) {
121
		if ($circle->getType() !== Circle::CIRCLES_CLOSED) {
122
			return;
123
		}
124
125
		$this->parseCircleMemberAdvancedEvent(
126
			$event, $circle, $member,
127
			$this->l10n->t("You accepted {member}'s request to join {circle}"),
128
			$this->l10n->t('Your request to join {circle} has been accepted by {author}'),
129
			$this->l10n->t("{member}'s request to join {circle} has been accepted by {author}")
130
		);
131
132
		throw new FakeException();
133
	}
134
135
136
	/**
137
	 * Parse on Subject 'member_left'.
138
	 * If circle is closed and member was not a real member, we send him to
139
	 * parseSubjectNonMemberLeftClosedCircle();
140
	 *
141
	 * @param IEvent $event
142
	 * @param Circle $circle
143
	 * @param Member $member
144
	 *
145
	 * @throws FakeException
146
	 */
147
	public function parseSubjectMemberLeft(IEvent &$event, Circle $circle, Member $member) {
148
149
		if ($event->getSubject() !== 'member_left') {
150
			return;
151
		}
152
153
		$this->parseSubjectNonMemberLeftClosedCircle($event, $circle, $member);
154
		$this->parseCircleMemberEvent(
155
			$event, $circle, $member,
156
			$this->l10n->t('You left {circle}'),
157
			$this->l10n->t('{member} left {circle}')
158
		);
159
160
		throw new FakeException();
161
	}
162
163
164
	/**
165
	 * Parse on Subject 'member_left' on a closed circle when user were not yet a member.
166
	 * If status is Invited we say that member rejected his invitation.
167
	 * If status is Requested we say he dismissed his request.
168
	 *
169
	 * @param IEvent $event
170
	 * @param Circle $circle
171
	 * @param Member $member
172
	 *
173
	 * @throws FakeException
174
	 */
175 View Code Duplication
	public function parseSubjectNonMemberLeftClosedCircle(IEvent &$event, Circle $circle, Member $member
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 101 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
176
	) {
177
		if ($circle->getType() !== Circle::CIRCLES_CLOSED
178
			|| $member->getLevel() !== Member::LEVEL_NONE) {
179
			return;
180
		}
181
182
		if ($member->getStatus() === Member::STATUS_INVITED) {
183
			$this->parseCircleMemberEvent(
184
				$event, $circle, $member,
185
				$this->l10n->t("You declined the invitation to join {circle}"),
186
				$this->l10n->t("{member} declined an invitation to join {circle}")
187
			);
188
		} else {
189
			$this->parseCircleMemberEvent(
190
				$event, $circle, $member,
191
				$this->l10n->t("You cancelled your request to join {circle}"),
192
				$this->l10n->t("{member} cancelled his request to join {circle}")
193
			);
194
		}
195
196
		throw new FakeException();
197
	}
198
199
200
	/**
201
	 * Parse on Subject 'member_remove'.
202
	 * If circle is closed and member was not a real member, we send him to
203
	 * parseSubjectNonMemberRemoveClosedCircle();
204
	 *
205
	 * @param IEvent $event
206
	 * @param Circle $circle
207
	 * @param Member $member
208
	 *
209
	 * @throws FakeException
210
	 */
211 View Code Duplication
	public function parseSubjectMemberRemove(IEvent &$event, Circle $circle, Member $member) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
212
213
		if ($event->getSubject() !== 'member_remove') {
214
			return;
215
		}
216
217
		if ($circle->getType() === Circle::CIRCLES_CLOSED
218
			&& $member->getLevel() === Member::LEVEL_NONE) {
219
			$this->parseSubjectNonMemberRemoveClosedCircle($event, $circle, $member);
220
221
		} else {
222
			$this->parseCircleMemberAdvancedEvent(
223
				$event, $circle, $member,
224
				$this->l10n->t('You removed {member} from {circle}'),
225
				$this->l10n->t('You have been removed from {circle} by {author}'),
226
				$this->l10n->t('{member} has been removed from {circle} by {author}')
227
			);
228
		}
229
230
		throw new FakeException();
231
	}
232
233
234
	/**
235
	 * Parse on Subject 'member_remove' on a closed circle when user were not yet a member.
236
	 * If status is Invited we say that author cancelled his invitation.
237
	 * If status is Requested we say that his invitation was rejected.
238
	 *
239
	 * @param IEvent $event
240
	 * @param Circle $circle
241
	 * @param Member $member
242
	 *
243
	 * @return IEvent
0 ignored issues
show
Documentation introduced by
Should the return type not be IEvent|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
244
	 */
245
	public function parseSubjectNonMemberRemoveClosedCircle(
246
		IEvent &$event, Circle $circle, Member $member
247
	) {
248
		if ($member->getStatus() === Member::STATUS_REQUEST) {
249
			return $this->parseCircleMemberAdvancedEvent(
250
				$event, $circle, $member,
251
				$this->l10n->t("You dismissed {member}'s request to join {circle}"),
252
				$this->l10n->t('Your request to join {circle} has been dismissed by {author}'),
253
				$this->l10n->t("{member}'s request to join {circle} has been dismissed by {author}")
254
			);
255
		}
256
257
		return $this->parseCircleMemberAdvancedEvent(
258
			$event, $circle, $member,
259
			$this->l10n->t("You cancelled {member}'s invitation to join {circle}"),
260
			$this->l10n->t('Your invitation to join {circle} has been cancelled by {author}'),
261
			$this->l10n->t("{author} cancelled {member}'s invitation to join {circle}")
262
		);
263
	}
264
265
266
	/**
267
	 * @param IEvent $event
268
	 * @param Circle $circle
269
	 * @param Member $group
270
	 *
271
	 * @throws FakeException
272
	 */
273 View Code Duplication
	public function parseGroupLink(IEvent &$event, Circle $circle, Member $group) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
274
		if ($event->getSubject() !== 'group_link') {
275
			return;
276
		}
277
278
		$this->parseCircleMemberEvent(
279
			$event, $circle, $group,
280
			$this->l10n->t('You linked {group} to {circle}'),
281
			$this->l10n->t('{group} has been linked to {circle} by {author}')
282
		);
283
		throw new FakeException();
284
	}
285
286
287
	/**
288
	 * @param IEvent $event
289
	 * @param Circle $circle
290
	 * @param Member $group
291
	 *
292
	 * @throws FakeException
293
	 */
294 View Code Duplication
	public function parseGroupUnlink(IEvent &$event, Circle $circle, Member $group) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
295
		if ($event->getSubject() !== 'group_unlink') {
296
			return;
297
		}
298
		$this->parseCircleMemberEvent(
299
			$event, $circle, $group,
300
			$this->l10n->t('You unlinked {group} from {circle}'),
301
			$this->l10n->t('{group} has been unlinked from {circle} by {author}')
302
		);
303
304
		throw new FakeException();
305
	}
306
307
308
	/**
309
	 * @param IEvent $event
310
	 * @param Circle $circle
311
	 * @param Member $group
312
	 *
313
	 * @throws FakeException
314
	 */
315
	public function parseGroupLevel(IEvent &$event, Circle $circle, Member $group) {
316
		if ($event->getSubject() !== 'group_level') {
317
			return;
318
		}
319
320
		$l = $this->l10n;
321
322
		$level = [$l->t($group->getLevelString())];
323
		$this->parseCircleMemberEvent(
324
			$event, $circle, $group,
325
			$l->t('You changed the level of the linked group {group} in {circle} to %1$s', $level),
326
			$l->t('{author} changed the level of the linked group {group} in {circle} to %1$s', $level)
327
		);
328
329
		throw new FakeException();
330
	}
331
332
333
	/**
334
	 * @param IEvent $event
335
	 * @param Circle $circle
336
	 * @param Member $member
337
	 *
338
	 * @throws FakeException
339
	 */
340 View Code Duplication
	public function parseMemberInvited(IEvent &$event, Circle $circle, Member $member) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
341
		if ($event->getSubject() !== 'member_invited') {
342
			return;
343
		}
344
345
		$this->parseCircleMemberAdvancedEvent(
346
			$event, $circle, $member,
347
			$this->l10n->t('You invited {member} to join {circle}'),
348
			$this->l10n->t('You have been invited to join {circle} by {author}'),
349
			$this->l10n->t('{member} has been invited to join {circle} by {author}')
350
		);
351
352
		throw new FakeException();
353
	}
354
355
356
	/**
357
	 * @param IEvent $event
358
	 * @param Circle $circle
359
	 * @param Member $member
360
	 *
361
	 * @throws FakeException
362
	 */
363 View Code Duplication
	public function parseMemberLevel(IEvent &$event, Circle $circle, Member $member) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
364
		if ($event->getSubject() !== 'member_level') {
365
			return;
366
		}
367
368
		$level = [$this->l10n->t($member->getLevelString())];
369
		$this->parseCircleMemberAdvancedEvent(
370
			$event, $circle, $member,
371
			$this->l10n->t('You changed {member}\'s level in {circle} to %1$s', $level),
372
			$this->l10n->t('{author} changed your level in {circle} to %1$s', $level),
373
			$this->l10n->t('{author} changed {member}\'s level in {circle} to %1$s', $level)
374
		);
375
376
		throw new FakeException();
377
	}
378
379
380
	/**
381
	 * @param IEvent $event
382
	 * @param Circle $circle
383
	 * @param Member $member
384
	 *
385
	 * @throws FakeException
386
	 */
387 View Code Duplication
	public function parseMemberRequestInvitation(IEvent &$event, Circle $circle, Member $member) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
388
		if ($event->getSubject() !== 'member_request_invitation') {
389
			return;
390
		}
391
392
		$this->parseMemberEvent(
393
			$event, $circle, $member,
394
			$this->l10n->t('You sent a request to join {circle}'),
395
			$this->l10n->t('{member} sent a request to join {circle}')
396
		);
397
398
		throw new FakeException();
399
	}
400
401
402
	/**
403
	 * @param IEvent $event
404
	 * @param Circle $circle
405
	 * @param Member $member
406
	 *
407
	 * @throws FakeException
408
	 */
409 View Code Duplication
	public function parseMemberOwner(IEvent &$event, Circle $circle, Member $member) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
410
		if ($event->getSubject() !== 'member_owner') {
411
			return;
412
		}
413
414
		$this->parseMemberEvent(
415
			$event, $circle, $member,
416
			$this->l10n->t('You are the new owner of {circle}'),
417
			$this->l10n->t('{member} is the new owner of {circle}')
418
		);
419
		throw new FakeException();
420
	}
421
422
423
	/**
424
	 * @param IEvent $event
425
	 * @param Circle $circle
426
	 * @param FederatedLink $remote
427
	 *
428
	 * @throws FakeException
429
	 */
430 View Code Duplication
	public function parseLinkRequestSent(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
431
		if ($event->getSubject() !== 'link_request_sent') {
432
			return;
433
		}
434
435
		$this->parseCircleEvent(
436
			$event, $circle, $remote,
437
			$this->l10n->t('You sent a request to link {circle} with {remote}'),
438
			$this->l10n->t('{author} sent a request to link {circle} with {remote}')
439
		);
440
441
		throw new FakeException();
442
	}
443
444
445
	/**
446
	 * @param IEvent $event
447
	 * @param Circle $circle
448
	 * @param FederatedLink $remote
449
	 *
450
	 * @throws FakeException
451
	 */
452 View Code Duplication
	public function parseLinkRequestReceived(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
453
		if ($event->getSubject() !== 'link_request_received') {
454
			return;
455
		}
456
457
		$this->parseLinkEvent(
458
			$event, $circle, $remote, $this->l10n->t('{remote} requested a link with {circle}')
459
		);
460
461
		throw new FakeException();
462
	}
463
464
465
	/**
466
	 * @param IEvent $event
467
	 * @param Circle $circle
468
	 * @param FederatedLink $remote
469
	 *
470
	 * @throws FakeException
471
	 */
472 View Code Duplication
	public function parseLinkRequestRejected(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
473
		if ($event->getSubject() !== 'link_request_rejected') {
474
			return;
475
		}
476
477
		$this->parseLinkEvent(
478
			$event, $circle, $remote,
479
			$this->l10n->t('The request to link {circle} with {remote} has been rejected')
480
		);
481
482
		throw new FakeException();
483
	}
484
485
486
	/**
487
	 * @param IEvent $event
488
	 * @param Circle $circle
489
	 * @param FederatedLink $remote
490
	 *
491
	 * @throws FakeException
492
	 */
493 View Code Duplication
	public function parseLinkRequestCanceled(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
494
		if ($event->getSubject() !== 'link_request_canceled') {
495
			return;
496
		}
497
498
		$this->parseLinkEvent(
499
			$event, $circle, $remote,
500
			$this->l10n->t(
501
				'The request to link {remote} with {circle} has been canceled remotely'
502
			)
503
		);
504
505
		throw new FakeException();
506
	}
507
508
509
	/**
510
	 * @param IEvent $event
511
	 * @param Circle $circle
512
	 * @param FederatedLink $remote
513
	 *
514
	 * @throws FakeException
515
	 */
516 View Code Duplication
	public function parseLinkRequestAccepted(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
517
		if ($event->getSubject() !== 'link_request_accepted') {
518
			return;
519
		}
520
521
		$this->parseLinkEvent(
522
			$event, $circle, $remote,
523
			$this->l10n->t('The request to link {circle} with {remote} has been accepted')
524
		);
525
526
		throw new FakeException();
527
	}
528
529
530
	/**
531
	 * @param IEvent $event
532
	 * @param Circle $circle
533
	 * @param FederatedLink $remote
534
	 *
535
	 * @throws FakeException
536
	 */
537 View Code Duplication
	public function parseLinkRequestRemoved(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
538
		if ($event->getSubject() !== 'link_request_removed') {
539
			return;
540
		}
541
542
		$this->parseCircleEvent(
543
			$event, $circle, $remote,
544
			$this->l10n->t('You dismissed the request to link {remote} with {circle}'),
545
			$this->l10n->t('{author} dismissed the request to link {remote} with {circle}')
546
		);
547
548
		throw new FakeException();
549
	}
550
551
552
	/**
553
	 * @param IEvent $event
554
	 * @param Circle $circle
555
	 * @param FederatedLink $remote
556
	 *
557
	 * @throws FakeException
558
	 */
559 View Code Duplication
	public function parseLinkRequestCanceling(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
560
		if ($event->getSubject() !== 'link_request_canceling') {
561
			return;
562
		}
563
564
		$this->parseCircleEvent(
565
			$event, $circle, $remote,
566
			$this->l10n->t('You canceled the request to link {circle} with {remote}'),
567
			$this->l10n->t('{author} canceled the request to link {circle} with {remote}')
568
		);
569
570
		throw new FakeException();
571
	}
572
573
574
	/**
575
	 * @param IEvent $event
576
	 * @param Circle $circle
577
	 * @param FederatedLink $remote
578
	 *
579
	 * @throws FakeException
580
	 */
581 View Code Duplication
	public function parseLinkRequestAccepting(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
582
		if ($event->getSubject() !== 'link_request_accepting') {
583
			return;
584
		}
585
586
		$this->parseCircleEvent(
587
			$event, $circle, $remote,
588
			$this->l10n->t('You accepted the request to link {remote} with {circle}'),
589
			$this->l10n->t('{author} accepted the request to link {remote} with {circle}')
590
		);
591
592
		throw new FakeException();
593
	}
594
595
596
	/**
597
	 * @param IEvent $event
598
	 * @param Circle $circle
599
	 * @param FederatedLink $remote
600
	 *
601
	 * @throws FakeException
602
	 */
603 View Code Duplication
	public function parseLinkUp(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
604
		if ($event->getSubject() !== 'link_up') {
605
			return;
606
		}
607
608
		$this->parseLinkEvent(
609
			$event, $circle, $remote,
610
			$this->l10n->t('A link between {circle} and {remote} is now up and running')
611
		);
612
613
		throw new FakeException();
614
	}
615
616
617
	/**
618
	 * @param IEvent $event
619
	 * @param Circle $circle
620
	 * @param FederatedLink $remote
621
	 *
622
	 * @throws FakeException
623
	 */
624 View Code Duplication
	public function parseLinkDown(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
625
		if ($event->getSubject() !== 'link_down') {
626
			return;
627
		}
628
629
		$this->parseLinkEvent(
630
			$event, $circle, $remote,
631
			$this->l10n->t(
632
				'The link between {circle} and {remote} has been shutdown remotely'
633
			)
634
		);
635
636
		throw new FakeException();
637
	}
638
639
640
	/**
641
	 * @param IEvent $event
642
	 * @param Circle $circle
643
	 * @param FederatedLink $remote
644
	 *
645
	 * @throws FakeException
646
	 */
647 View Code Duplication
	public function parseLinkRemove(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
648
		if ($event->getSubject() !== 'link_remove') {
649
			return;
650
		}
651
652
		$this->parseCircleEvent(
653
			$event, $circle, $remote,
654
			$this->l10n->t('You closed the link between {circle} and {remote}'),
655
			$this->l10n->t('{author} closed the link between {circle} and {remote}')
656
		);
657
658
		throw new FakeException();
659
	}
660
}