Completed
Pull Request — master (#362)
by Maxence
02:54
created

MemberLeave   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 21.28 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 7
dl 10
loc 47
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A verify() 0 8 1
A manage() 10 10 1
A result() 0 2 1

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 declare(strict_types=1);
2
3
4
/**
5
 * Circles - Bring cloud-users closer together.
6
 *
7
 * This file is licensed under the Affero General Public License version 3 or
8
 * later. See the COPYING file.
9
 *
10
 * @author Maxence Lange <[email protected]>
11
 * @copyright 2017
12
 * @license GNU AGPL version 3 or any later version
13
 *
14
 * This program is free software: you can redistribute it and/or modify
15
 * it under the terms of the GNU Affero General Public License as
16
 * published by the Free Software Foundation, either version 3 of the
17
 * License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU Affero General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU Affero General Public License
25
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
26
 *
27
 */
28
29
30
namespace OCA\Circles\GlobalScale;
31
32
33
use OCA\Circles\Exceptions\CircleDoesNotExistException;
34
use OCA\Circles\Exceptions\ConfigNoCircleAvailableException;
35
use OCA\Circles\Exceptions\GlobalScaleDSyncException;
36
use OCA\Circles\Exceptions\GlobalScaleEventException;
37
use OCA\Circles\Exceptions\MemberDoesNotExistException;
38
use OCA\Circles\Exceptions\MemberIsOwnerException;
39
use OCA\Circles\Model\GlobalScale\GSEvent;
40
41
42
/**
43
 * Class MemberLeave
44
 *
45
 * @package OCA\Circles\GlobalScale
46
 */
47
class MemberLeave extends AGlobalScaleEvent {
48
49
50
	/**
51
	 * @param GSEvent $event
52
	 * @param bool $localCheck
53
	 * @param bool $mustBeChecked
54
	 *
55
	 * @throws MemberDoesNotExistException
56
	 * @throws MemberIsOwnerException
57
	 * @throws CircleDoesNotExistException
58
	 * @throws ConfigNoCircleAvailableException
59
	 * @throws GlobalScaleDSyncException
60
	 * @throws GlobalScaleEventException
61
	 */
62
	public function verify(GSEvent $event, bool $localCheck = false, bool $mustBeChecked = false): void {
63
		parent::verify($event, $localCheck, true);
64
65
		$member = $event->getMember();
66
67
		$member->hasToBeMemberOrAlmost();
68
		$member->cantBeOwner();
69
	}
70
71
72
	/**
73
	 * @param GSEvent $event
74
	 */
75 View Code Duplication
	public function manage(GSEvent $event): void {
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...
76
		$circle = $event->getCircle();
77
		$member = $event->getMember();
78
79
		$this->eventsService->onMemberLeaving($circle, $member);
80
81
		$this->membersRequest->removeMember($member);
82
		$this->sharesRequest->removeSharesFromMember($member);
83
		$this->gsSharesRequest->removeGSSharesFromMember($member);
84
	}
85
86
87
	/**
88
	 * @param GSEvent[] $events
89
	 */
90
	public function result(array $events): void {
91
	}
92
93
}
94
95