Code Duplication    Length = 25-28 lines in 2 locations

lib/Service/GroupsService.php 1 location

@@ 228-252 (lines=25) @@
225
	 * @return array
226
	 * @throws \Exception
227
	 */
228
	public function unlinkGroup($circleUniqueId, $groupId) {
229
		try {
230
			$circle = $this->circlesRequest->getCircle($circleUniqueId, $this->userId);
231
			$circle->getHigherViewer()
232
				   ->hasToBeAdmin();
233
234
			$group = $this->membersRequest->forceGetGroup($circleUniqueId, $groupId);
235
			$group->cantBeOwner();
236
			$circle->getHigherViewer()
237
				   ->hasToBeHigherLevel($group->getLevel());
238
239
			$group->setLevel(Member::LEVEL_NONE);
240
			$this->membersRequest->updateGroup($group);
241
242
243
			$this->eventsService->onGroupUnlink($circle, $group);
244
245
		} catch (\Exception $e) {
246
			throw $e;
247
		}
248
249
		return $this->membersRequest->getGroupsFromCircle(
250
			$circle->getUniqueId(), $circle->getHigherViewer()
251
		);
252
	}
253
254
255
	/**

lib/Service/MembersService.php 1 location

@@ 109-136 (lines=28) @@
106
	 * @return array
107
	 * @throws \Exception
108
	 */
109
	public function addLocalMember($circleUniqueId, $name) {
110
111
		try {
112
			$circle = $this->circlesRequest->getCircle($circleUniqueId, $this->userId);
113
			$circle->getHigherViewer()
114
				   ->hasToBeModerator();
115
		} catch (\Exception $e) {
116
			throw $e;
117
		}
118
119
		try {
120
			$member =
121
				$this->membersRequest->getFreshNewMember($circleUniqueId, $name, Member::TYPE_USER);
122
			$member->hasToBeInviteAble();
123
124
		} catch (\Exception $e) {
125
			throw $e;
126
		}
127
128
		$member->inviteToCircle($circle->getType());
129
		$this->membersRequest->updateMember($member);
130
131
		$this->eventsService->onMemberNew($circle, $member);
132
133
		return $this->membersRequest->getMembers(
134
			$circle->getUniqueId(), $circle->getHigherViewer()
135
		);
136
	}
137
138
139
	/**