Code Duplication    Length = 27-28 lines in 2 locations

lib/Controller/GroupsController.php 2 locations

@@ 45-71 (lines=27) @@
42
	 * @return DataResponse
43
	 * @throws LinkedGroupNotAllowedException
44
	 */
45
	public function add($id, $name) {
46
		if (!$this->configService->isLinkedGroupsAllowed()) {
47
			throw new LinkedGroupNotAllowedException(
48
				$this->l10n->t("Linked Groups are not allowed on this Nextcloud")
49
			);
50
		}
51
52
		try {
53
			$data = $this->groupsService->linkGroup($id, $name);
54
		} catch (\Exception $e) {
55
			return $this->fail(
56
				[
57
					'circle_id' => $id,
58
					'name'      => $name,
59
					'error'     => $e->getMessage()
60
				]
61
			);
62
		}
63
64
		return $this->success(
65
			[
66
				'circle_id' => $id,
67
				'name'      => $name,
68
				'groups'    => $data
69
			]
70
		);
71
	}
72
73
74
	/**
@@ 121-148 (lines=28) @@
118
	 * @return DataResponse
119
	 * @throws LinkedGroupNotAllowedException
120
	 */
121
	public function remove($id, $group) {
122
		if (!$this->configService->isLinkedGroupsAllowed()) {
123
			throw new LinkedGroupNotAllowedException(
124
				$this->l10n->t("Linked Groups are not allowed on this Nextcloud")
125
			);
126
		}
127
128
		try {
129
			$data = $this->groupsService->unlinkGroup($id, $group);
130
		} catch (\Exception $e) {
131
			return
132
				$this->fail(
133
					[
134
						'circle_id' => $id,
135
						'name'      => $group,
136
						'error'     => $e->getMessage()
137
					]
138
				);
139
		}
140
141
		return $this->success(
142
			[
143
				'circle_id' => $id,
144
				'name'      => $group,
145
				'groups'    => $data,
146
			]
147
		);
148
	}
149
150
151
}