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

MemberDelete::manage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 1
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\MemberAlreadyExistsException;
34
use OCA\Circles\Exceptions\MemberDoesNotExistException;
35
use OCA\Circles\Exceptions\MemberIsNotModeratorException;
36
use OCA\Circles\Exceptions\MemberIsOwnerException;
37
use OCA\Circles\Exceptions\ModeratorIsNotHighEnoughException;
38
use OCA\Circles\Model\GlobalScale\GSEvent;
39
40
41
/**
42
 * Class MemberDelete
43
 *
44
 * @package OCA\Circles\GlobalScale
45
 */
46
class MemberDelete extends AGlobalScaleEvent {
47
48
49
	/**
50
	 * @param GSEvent $event
51
	 * @param bool $localCheck
52
	 * @param bool $mustBeChecked
53
	 *
54
	 * @throws MemberDoesNotExistException
55
	 * @throws MemberIsNotModeratorException
56
	 * @throws MemberIsOwnerException
57
	 * @throws ModeratorIsNotHighEnoughException
58
	 */
59
	public function verify(GSEvent $event, bool $localCheck = false, bool $mustBeChecked = false): void {
60
		$circle = $event->getCircle();
61
		$member = $event->getMember();
62
63
		$circle->getHigherViewer()
64
			   ->hasToBeModerator();
65
66
		$member->hasToBeMemberOrAlmost();
67
		$member->cantBeOwner();
68
69
		$circle->getHigherViewer()
70
			   ->hasToBeHigherLevel($member->getLevel());
71
	}
72
73
74
	/**
75
	 * @param GSEvent $event
76
	 *
77
	 * @throws MemberAlreadyExistsException
78
	 */
79 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...
80
		$circle = $event->getCircle();
81
		$member = $event->getMember();
82
83
		$this->eventsService->onMemberLeaving($circle, $member);
84
		$this->membersRequest->removeMember($member);
85
		// TODO: remove shares to this member
86
//		$this->sharesRequest->removeSharesFromMember($member);
87
//		$this->tokensRequest->removeTokensFromMember($member);
88
89
//		return $this->membersRequest->getMembers(
90
//			$circle->getUniqueId(), $circle->getHigherViewer()
91
//		);
92
	}
93
94
}
95
96