Code Duplication    Length = 16-17 lines in 2 locations

apps/provisioning_api/lib/Controller/GroupsController.php 1 location

@@ 184-200 (lines=17) @@
181
	 * @return DataResponse
182
	 * @throws OCSException
183
	 */
184
	public function getSubAdminsOfGroup(string $groupId): DataResponse {
185
		// Check group exists
186
		$targetGroup = $this->groupManager->get($groupId);
187
		if($targetGroup === null) {
188
			throw new OCSException('Group does not exist', 101);
189
		}
190
191
		/** @var IUser[] $subadmins */
192
		$subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup);
193
		// New class returns IUser[] so convert back
194
		$uids = [];
195
		foreach ($subadmins as $user) {
196
			$uids[] = $user->getUID();
197
		}
198
199
		return new DataResponse($uids);
200
	}
201
202
}
203

apps/provisioning_api/lib/Controller/UsersController.php 1 location

@@ 829-844 (lines=16) @@
826
	 * @return array
827
	 * @throws OCSException
828
	 */
829
	protected function getUserSubAdminGroupsData(string $userId): array {
830
		$user = $this->userManager->get($userId);
831
		// Check if the user exists
832
		if($user === null) {
833
			throw new OCSException('User does not exist', 101);
834
		}
835
836
		// Get the subadmin groups
837
		$subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user);
838
		$groups = [];
839
		foreach ($subAdminGroups as $key => $group) {
840
			$groups[] = $group->getGID();
841
		}
842
843
		return $groups;
844
	}
845
846
	/**
847
	 * Get the groups a user is a subadmin of