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
	 * check if value for showWeekNr is allowed
@@ 307-320 (lines=14) @@
304
	 *
305
	 * @return JSONResponse
306
	 */
307
	private function setFirstRun() {
308
		try {
309
			$this->config->setUserValue(
310
				$this->userId,
311
				$this->appName,
312
				'firstRun',
313
				'no'
314
			);
315
		} catch(\Exception $e) {
316
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
317
		}
318
319
		return new JSONResponse();
320
	}
321
322
	/**
323
	 * get stored value for first run
@@ 327-342 (lines=16) @@
324
	 *
325
	 * @return JSONResponse
326
	 */
327
	private function getFirstRun() {
328
		try {
329
			$value = $this->config->getUserValue(
330
				$this->userId,
331
				$this->appName,
332
				'firstRun',
333
				'yes'
334
			);
335
		} catch(\Exception $e) {
336
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
337
		}
338
339
		return new JSONResponse([
340
			'value' => $value,
341
		]);
342
	}
343
344
	/**
345
	 * sets display timezone for user
@@ 350-363 (lines=14) @@
347
	 * @param string $value
348
	 * @return JSONResponse
349
	 */
350
	private function setTimezone($value) {
351
		try {
352
			$this->config->setUserValue(
353
				$this->userId,
354
				$this->appName,
355
				'timezone',
356
				$value
357
			);
358
		} catch(\Exception $e) {
359
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
360
		}
361
362
		return new JSONResponse();
363
	}
364
365
	/**
366
	 * gets display timezone for user
@@ 370-385 (lines=16) @@
367
	 *
368
	 * @return JSONResponse
369
	 */
370
	private function getTimezone() {
371
		try {
372
			$value = $this->config->getUserValue(
373
				$this->userId,
374
				$this->appName,
375
				'timezone',
376
				'automatic'
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