Code Duplication    Length = 14-16 lines in 5 locations

controller/settingscontroller.php 5 locations

@@ 141-156 (lines=16) @@
138
	 *
139
	 * @return JSONResponse
140
	 */
141
	private function getView() {
142
		try {
143
			$view = $this->config->getUserValue(
144
				$this->userId,
145
				$this->appName,
146
				'currentView',
147
				'month'
148
			);
149
		} catch(\Exception $e) {
150
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
151
		}
152
153
		return new JSONResponse([
154
			'value' => $view,
155
		]);
156
	}
157
158
	/**
159
	 * check if view is allowed
@@ 204-219 (lines=16) @@
201
	 *
202
	 * @return JSONResponse
203
	 */
204
	private function getSkipPopover() {
205
		try {
206
			$view = $this->config->getUserValue(
207
				$this->userId,
208
				$this->appName,
209
				'skipPopover',
210
				'no'
211
			);
212
		} catch(\Exception $e) {
213
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
214
		}
215
216
		return new JSONResponse([
217
			'value' => $view,
218
		]);
219
	}
220
221
	/**
222
	 * check if value for skipPopover is allowed
@@ 266-281 (lines=16) @@
263
	 *
264
	 * @return JSONResponse
265
	 */
266
	private function getShowWeekNr() {
267
		try {
268
			$value = $this->config->getUserValue(
269
				$this->userId,
270
				$this->appName,
271
				'showWeekNr',
272
				'no'
273
			);
274
		} catch(\Exception $e) {
275
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
276
		}
277
278
		return new JSONResponse([
279
			'value' => $value,
280
		]);
281
	}
282
283
	/**
284
	 * check if value for showWeekNr is allowed
@@ 303-316 (lines=14) @@
300
	 *
301
	 * @return JSONResponse
302
	 */
303
	private function setFirstRun() {
304
		try {
305
			$this->config->setUserValue(
306
				$this->userId,
307
				$this->appName,
308
				'firstRun',
309
				'no'
310
			);
311
		} catch(\Exception $e) {
312
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
313
		}
314
315
		return new JSONResponse();
316
	}
317
318
	/**
319
	 * get stored value for first run
@@ 323-338 (lines=16) @@
320
	 *
321
	 * @return JSONResponse
322
	 */
323
	private function getFirstRun() {
324
		try {
325
			$value = $this->config->getUserValue(
326
				$this->userId,
327
				$this->appName,
328
				'firstRun',
329
				'yes'
330
			);
331
		} catch(\Exception $e) {
332
			return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
333
		}
334
335
		return new JSONResponse([
336
			'value' => $value,
337
		]);
338
	}
339
}
340