Code Duplication    Length = 23-24 lines in 4 locations

lib/Controller/CirclesController.php 4 locations

@@ 137-160 (lines=24) @@
134
	 *
135
	 * @return DataResponse
136
	 */
137
	public function list($type, $name = '') {
138
139
		try {
140
			$data = $this->circlesService->listCircles($type, $name, Member::LEVEL_NONE);
141
		} catch (CircleTypeDisabledException $e) {
142
			return
143
				new DataResponse(
144
					[
145
						'type'   => $type,
146
						'status' => 0,
147
						'error'  => $e->getMessage()
148
					],
149
					Http::STATUS_NON_AUTHORATIVE_INFORMATION
150
				);
151
		}
152
153
		return new DataResponse(
154
			[
155
				'type'   => $type,
156
				'data'   => $data,
157
				'status' => 1
158
			], Http::STATUS_CREATED
159
		);
160
	}
161
162
163
	/**
@@ 173-196 (lines=24) @@
170
	 * @internal param string $name
171
	 *
172
	 */
173
	public function details($id) {
174
175
		try {
176
			$data = $this->circlesService->detailsCircle($id);
177
		} catch (CircleDoesNotExistException $e) {
178
			return
179
				new DataResponse(
180
					[
181
						'circle_id' => $id,
182
						'status'    => 0,
183
						'error'     => $e->getMessage()
184
					],
185
					Http::STATUS_NON_AUTHORATIVE_INFORMATION
186
				);
187
		}
188
189
		return new DataResponse(
190
			[
191
				'circle_id' => $id,
192
				'details'   => $data,
193
				'status'    => 1
194
			], Http::STATUS_CREATED
195
		);
196
	}
197
198
199
	/**
@@ 209-232 (lines=24) @@
206
	 * @internal param string $name
207
	 *
208
	 */
209
	public function join($id) {
210
211
		try {
212
			$data = $this->circlesService->joinCircle($id);
213
		} catch (\Exception $e) {
214
			return
215
				new DataResponse(
216
					[
217
						'circle_id' => $id,
218
						'status'    => 0,
219
						'error'     => $e->getMessage()
220
					],
221
					Http::STATUS_NON_AUTHORATIVE_INFORMATION
222
				);
223
		}
224
225
		return new DataResponse(
226
			[
227
				'circle_id' => $id,
228
				'member'    => $data,
229
				'status'    => 1
230
			], Http::STATUS_CREATED
231
		);
232
	}
233
234
235
	/**
@@ 245-267 (lines=23) @@
242
	 * @internal param string $name
243
	 *
244
	 */
245
	public function leave($id) {
246
		try {
247
			$data = $this->circlesService->leaveCircle($id);
248
		} catch (\Exception $e) {
249
			return
250
				new DataResponse(
251
					[
252
						'circle_id' => $id,
253
						'status'    => 0,
254
						'error'     => $e->getMessage()
255
					],
256
					Http::STATUS_NON_AUTHORATIVE_INFORMATION
257
				);
258
		}
259
260
		return new DataResponse(
261
			[
262
				'circle_id' => $id,
263
				'member'    => $data,
264
				'status'    => 1
265
			], Http::STATUS_CREATED
266
		);
267
	}
268
269
270