Completed
Push — master ( 2813c1...14a1cb )
by Maxence
01:59
created

ProviderSubjectGroup::parseGroupUnlink()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 12
loc 12
rs 9.4285
cc 2
eloc 8
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 ProviderSubjectGroup extends ProviderParser {
38
39
40
	/**
41
	 * @param IEvent $event
42
	 * @param Circle $circle
43
	 * @param Member $group
44
	 *
45
	 * @throws FakeException
46
	 */
47 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...
48
		if ($event->getSubject() !== 'group_link') {
49
			return;
50
		}
51
52
		$this->parseCircleMemberEvent(
53
			$event, $circle, $group,
54
			$this->l10n->t('You linked {group} to {circle}'),
55
			$this->l10n->t('{group} has been linked to {circle} by {author}')
56
		);
57
		throw new FakeException();
58
	}
59
60
61
	/**
62
	 * @param IEvent $event
63
	 * @param Circle $circle
64
	 * @param Member $group
65
	 *
66
	 * @throws FakeException
67
	 */
68 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...
69
		if ($event->getSubject() !== 'group_unlink') {
70
			return;
71
		}
72
		$this->parseCircleMemberEvent(
73
			$event, $circle, $group,
74
			$this->l10n->t('You unlinked {group} from {circle}'),
75
			$this->l10n->t('{group} has been unlinked from {circle} by {author}')
76
		);
77
78
		throw new FakeException();
79
	}
80
81
82
	/**
83
	 * @param IEvent $event
84
	 * @param Circle $circle
85
	 * @param Member $group
86
	 *
87
	 * @throws FakeException
88
	 */
89
	public function parseGroupLevel(IEvent &$event, Circle $circle, Member $group) {
90
		if ($event->getSubject() !== 'group_level') {
91
			return;
92
		}
93
94
		$l = $this->l10n;
95
96
		$level = [$l->t($group->getLevelString())];
97
		$this->parseCircleMemberEvent(
98
			$event, $circle, $group,
99
			$l->t('You changed the level of the linked group {group} in {circle} to %1$s', $level),
100
			$l->t('{author} changed the level of the linked group {group} in {circle} to %1$s', $level)
101
		);
102
103
		throw new FakeException();
104
	}
105
106
107
}