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

ProviderSubjectCircle   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 56.52 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 26
loc 46
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parseSubjectCircleCreate() 13 13 2
A parseSubjectCircleDelete() 13 13 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 ProviderSubjectCircle extends ProviderParser {
38
39
40
	/**
41
	 * @param IEvent $event
42
	 * @param Circle $circle
43
	 *
44
	 * @throws FakeException
45
	 */
46 View Code Duplication
	public function parseSubjectCircleCreate(IEvent &$event, Circle $circle) {
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...
47
		if ($event->getSubject() !== 'circle_create') {
48
			return;
49
		}
50
51
		$this->parseCircleEvent(
52
			$event, $circle, null,
53
			$this->l10n->t('You created the circle {circle}'),
54
			$this->l10n->t('{author} created the circle {circle}')
55
		);
56
57
		throw new FakeException();
58
	}
59
60
61
	/**
62
	 * @param IEvent $event
63
	 * @param Circle $circle
64
	 *
65
	 * @throws FakeException
66
	 */
67 View Code Duplication
	public function parseSubjectCircleDelete(IEvent &$event, Circle $circle) {
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...
68
		if ($event->getSubject() !== 'circle_delete') {
69
			return;
70
		}
71
72
		$this->parseCircleEvent(
73
			$event, $circle, null,
74
			$this->l10n->t('You deleted {circle}'),
75
			$this->l10n->t('{author} deleted {circle}')
76
		);
77
78
		throw new FakeException();
79
	}
80
81
82
}