Code Duplication    Length = 14-16 lines in 7 locations

controller/settingscontroller.php 7 locations

@@ 145-160 (lines=16) @@
142
	 *
143
	 * @return JSONResponse
144
	 */
145
	private function getView() {
146
		try {
147
			$view = $this->config->getUserValue(
148
				$this->userId,
149
				$this->appName,
150
				'currentView',
151
				'month'
152
			);
153
		} catch(\Exception $e) {
154
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
155
		}
156
157
		return new JSONResponse([
158
			'value' => $view,
159
		]);
160
	}
161
162
	/**
163
	 * check if view is allowed
@@ 208-223 (lines=16) @@
205
	 *
206
	 * @return JSONResponse
207
	 */
208
	private function getSkipPopover() {
209
		try {
210
			$view = $this->config->getUserValue(
211
				$this->userId,
212
				$this->appName,
213
				'skipPopover',
214
				'no'
215
			);
216
		} catch(\Exception $e) {
217
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
218
		}
219
220
		return new JSONResponse([
221
			'value' => $view,
222
		]);
223
	}
224
225
	/**
226
	 * check if value for skipPopover is allowed
@@ 270-285 (lines=16) @@
267
	 *
268
	 * @return JSONResponse
269
	 */
270
	private function getShowWeekNr() {
271
		try {
272
			$value = $this->config->getUserValue(
273
				$this->userId,
274
				$this->appName,
275
				'showWeekNr',
276
				'no'
277
			);
278
		} catch(\Exception $e) {
279
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
280
		}
281
282
		return new JSONResponse([
283
			'value' => $value,
284
		]);
285
	}
286
287
	/**
288
	 * set config value for start of week
@@ 293-306 (lines=14) @@
290
	 * @param $value
291
	 * @return JSONResponse
292
	 */
293
	private function setStartOfWeek($value) {
294
		try {
295
			$this->config->setUserValue(
296
				$this->userId,
297
				$this->appName,
298
				'startOfWeek',
299
				$value
300
			);
301
		} catch(\Exception $e) {
302
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
303
		}
304
305
		return new JSONResponse();
306
	}
307
308
	/**
309
	 * get config value for start of week
@@ 313-328 (lines=16) @@
310
	 *
311
	 * @return JSONResponse
312
	 */
313
	private function getStartOfWeek() {
314
		try {
315
			$value = $this->config->getUserValue(
316
				$this->userId,
317
				$this->appName,
318
				'startOfWeek',
319
				''
320
			);
321
		} catch(\Exception $e) {
322
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
323
		}
324
325
		return new JSONResponse([
326
			'value' => $value,
327
		]);
328
	}
329
330
	/**
331
	 * check if value for showWeekNr is allowed
@@ 350-363 (lines=14) @@
347
	 *
348
	 * @return JSONResponse
349
	 */
350
	private function setFirstRun() {
351
		try {
352
			$this->config->setUserValue(
353
				$this->userId,
354
				$this->appName,
355
				'firstRun',
356
				'no'
357
			);
358
		} catch(\Exception $e) {
359
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
360
		}
361
362
		return new JSONResponse();
363
	}
364
365
	/**
366
	 * get stored value for first run
@@ 370-385 (lines=16) @@
367
	 *
368
	 * @return JSONResponse
369
	 */
370
	private function getFirstRun() {
371
		try {
372
			$value = $this->config->getUserValue(
373
				$this->userId,
374
				$this->appName,
375
				'firstRun',
376
				'yes'
377
			);
378
		} catch(\Exception $e) {
379
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
380
		}
381
382
		return new JSONResponse([
383
			'value' => $value,
384
		]);
385
	}
386
}
387